Type
CONTRACT
Validation date
2023-11-16 15:22:57 UTC
Fee
0.17187215 UCO

Code (819 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: 0x000080D5057516F335B1FA66F82ACCC4D05BBD983ED957B5D7D67505A4CFE10277FC, 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: 0x000080D5057516F335B1FA66F82ACCC4D05BBD983ED957B5D7D67505A4CFE10277FC, 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

    FF1E9AF4E54461099BB7A0527502EEBD01C6EE5329B4ED6730361BD9FE4B744B3C3D1EDACE9C801CB00B7A41AC8249E0AB5D66AD471A66BB4E99F045

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001F71E68B99963C62D38865691AC11FD2616F22292CAF14A05EB753CFA5B89A197

Previous signature

FFA1894FD377C126FB0B245771916B09534361C31A421846556B23CE3329D89B3BF24B5E954D1C95C9F317D1004A71B7C38612C7C97E0212CCC9FC0695E01605

Origin signature

3045022100EE15DF8CBF2F35AB4FBCBFB7DFCB2CDF2E4AE09910AFFDF4292C1CC9679270CA02201A5BB9803EB3EFEE8C97F585D7FE56F48197F77EC46E3725C97B43D955298232

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0087FCC340BD43D4870F6B3F23F6FE7846213882868AFE1F58CBCF43E4E4B3D79C

Coordinator signature

0BB6CAFE0BCA4904C3DB3E59ABF4E736FBB20FC11689BA56DD35DC7E06E8B06FC048DA97621E2A4C681E3ABF5ED1FB798B7710E229D90BC13CA8CA18498A460A

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

BD336930AE22201772EB143ED3C0F997A4F4040946D1D2B283F663784C1B9FD74C4D2669087EFD29F49E287D78DE1793B19E447F878B7AB962F3BAC91A70A70E

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

E538E0E64875FADA15BB873ED4EDAB4CCAF40172C0FFCB68768123129C40D2B78FF813EBDC09E881BD83571E73E9E70D685442341CA522FD0F0AFBDF8067CD05