Type
CONTRACT
Validation date
2023-11-22 12:54:34 UTC
Fee
0.19122002 UCO

Code (823 B)

@version 1

condition triggered_by: transaction, on: set_secret_hash(_secret_hash, _secret_hash_signature, _end_time), as: [
  previous_public_key: (
  # Transaction is not yet validated so we need to use previous address
  # to get the genesis address
  previous_address = Chain.get_previous_address()
	Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
)
]

actions triggered_by: transaction, on: set_secret_hash(secret_hash, secret_hash_signature, end_time) do
  next_code = """
  @version 1
  # Automate the refunding after the given timestamp
  actions triggered_by: datetime, at: #{end_time} do
    Contract.set_type "transfer"
  # Send back the token to the user address
  Contract.add_uco_transfer to: 0x00001675BECDA24450FAD82114A15B58567979E8E7AEA1CFFC54CE8C1779513EA2AF, amount: 0.018
  Contract.set_code ""

  end

  condition triggered_by: transaction, on: refund(), as: [
    timestamp: timestamp >= #{end_time}
  ]

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
  # Send back the token to the user address
  Contract.add_uco_transfer to: 0x00001675BECDA24450FAD82114A15B58567979E8E7AEA1CFFC54CE8C1779513EA2AF, amount: 0.018
  Contract.set_code ""

  end

  condition triggered_by: transaction, on: reveal_secret(secret, secret_signature), as: [
    previous_public_key: (
    # Transaction is not yet validated so we need to use previous address
    # to get the genesis address
    previous_address = Chain.get_previous_address()
	  Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
  ),
    timestamp: transaction.timestamp < #{end_time},
    content: Crypto.hash(String.to_hex(secret)) == 0x#{secret_hash}
  ]

  actions triggered_by: transaction, on: reveal_secret(secret, secret_signature) do
    next_code = """
    @version 1

    export fun get_secret() do
      [
        secret: 0x\#{secret},
        secret_signature: [
          r: 0x\#{secret_signature.r},
          s: 0x\#{secret_signature.s},
          v: \#{secret_signature.v}
        ]
      ]
    end

    \"""

    Contract.set_type "transfer"
    Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.017946
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.4e-5

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      amount: 0.017946,
      end_time: #{end_time},
      secret_hash: 0x#{secret_hash},
      secret_hash_signature: [
        r: 0x#{secret_hash_signature.r},
        s: 0x#{secret_hash_signature.s},
        v: #{secret_hash_signature.v}
      ]
    ]
  end

  """

  Contract.set_code next_code
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    07745524C714663F857CE2245450F37C94BADD0CA3F7905274FF7BCE67FB81FD09D9EF684DAB0C45A779C576141ED64A54097C956DADB0B4D7A5F2A1

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000137213F56A4A225061D1E98C3A388F7976931BD9800407FD7E4CF7AE9B5CF5FC5

Previous signature

397DE2DD9E2C3B6D2CA0564D3A46AB05703E378928B22A59F0305DFCB488AB7C5B123A7753362EE13CADAF0C5938E456CB10BB0AE0A57A9A702BF3B43AC60A0E

Origin signature

3045022100E43BB6D3388CC7C881ECA3B0CE2F86509DAF8A99557D1374B169713C13F0D4E9022069544DC43637F7D0A78D2FF228455E472FF2A3D88C169F7117893080CAEB377A

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00B0A6E220BA02F3C7E0BC2DAC9388890F6052563B1DDEC46B138F0A2D1860F3E0

Coordinator signature

7C7D0635A8FF74FE9E8621A9A4091E12DB0BEB69326F35F3215A2B58736F78986B54F2D7C9111CBD4DDC171700A4F5421E5128A432F20A6B1B6B7BA2D078BD03

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

C2FF15C14339050AC82FFFD4B2583C06BAD2A5F4919F42FDC59A364D50FE3F2EB275DF80BE2BB506B73395CF77E60D12C0120514EDA45C6BCDE0601D32AD2D06

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

EF4497CEC061B3FF6C25DC64110892C2AFF19C81D464DAAAC8F1DCCD50215D7D5E3A107A6D25A723283437636F9336F6433B9B186A18FC5EA10F0D5B50AA8F0A