Type
CONTRACT
Validation date
2023-12-02 16:21:08 UTC
Fee
0.21188105 UCO

Code (821 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: 0x0000C8BDA3C290FBD6725432B394D65B8A2A1D1BB1C8A5F326D5419AB826A0C2DADB, amount: 20
  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: 0x0000C8BDA3C290FBD6725432B394D65B8A2A1D1BB1C8A5F326D5419AB826A0C2DADB, amount: 20
  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: 19.94
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.06

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      amount: 19.94,
      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

    8C479FDEA64198FA0C52C8039F3EF909ADEA87CCB4B9BBED442FCB54E8FC1869FF45AC04CA7E45B7F74F6F705E8628915035B1F22A3D3E8852BFB61B

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000157786C7AF25BC94D927B479DC9EC96C7DF83385785B0DDF84BCA2411AEBCA52A

Previous signature

F8BA40EEEED124A8506DF3C7D4EEEFB69B3DAECE5425E61EE1EB7C4BD3689F559A74A01BFD9EC3535CB59F02705EB953F34B677DAED6F6140ABB0DB4CF4CB708

Origin signature

304402200C1FB7E5109437B7080C73A3EAF8C002744F88FF889F98CC1FECA16FA2A1899702200A664A5843F17950BC88A686507C75084505376B3B6EBD28B8A1A83057C5AEE5

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00C19EFC2F395DDF9E49D676A0670AC2C7855F886A9AAF9E4D58EA87BF4D437E03

Coordinator signature

82004E273516B6CADE1877203553D65D07BE8064CA9A104C816FCC69613EC27F3F6E0C0EF8B23074BBEC1DB5E3A702D2BBA96DDFA614E91F749C713DBCEC750E

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

DF53AED63ED1F37F3334D0CEFD764A534211C875D6E5757B3AAA25EE706190A98A531D429A9BBF4D1A22F56E5972EA8D7FA65ADA929D00B60201FBCC11DA030B

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

3D28FFF20FA7D9A06840ABD72F59881C5BCDF6B244D8279BB37A43AB4DA3CB555E92F099E1EE985E039F2B17E3F628E9F93F6B8A05C84A9807978532A9E96702