Type
CONTRACT
Validation date
2023-12-09 16:03:47 UTC
Fee
0.205025 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: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 2
  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: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 2
  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: 1.994
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006

    Contract.set_code next_code
  end

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

    C348F6EF9D6996D9FF77C75B0073EC13B6F47D1D9E053860DF25B32EC441F88540EC6FF3879625FA0E1EF31F139C84F8EC318DA14B0315DB03421390

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00012EEF4280A5BCB9ECC962C4B98DE0D99E0F2F9C48B9EB6D346D43D020937B21BE

Previous signature

DC33D77E34A9C957A983A80DED956ADCAD4957DA39C3B5E85E62DD1E4E64C1E2E6020B4D33E6F5B07CBF561CE64CF54717E3DECBCCB2E03FEECAF26D00179C05

Origin signature

3045022100FB82EBF4C1D83091090C903D4633334B033C2BF6F22B9D176F82D290A0745D2B02205D85B96A3EA1429EEDAFF8989F04128F0A4AECBAB0D1EA51E7F58103C34D8AFC

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00F3391713DEBBE5B2E4123BAA4ACDF0BD7FA85BAF725CB7BC1FF7D155A65FC180

Coordinator signature

AFB1C782E2025721D18878C6DB9F1FC05CF6C5296B29B07DF33FDCEAE97B690BECAA5226AD7BF8A8C37A3C5F2101BCA36884E717937BFFEEFDD1F99D5D62D800

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

B67E001E339D508D08CEC7EDB99ECE17CF2560A4B51809446D8453D270C078F7AEDBF31490C48D0EE1BD9E5A7234128F1662B8EE3F70979868904C2ACE083601

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

3866900ED2AF1EDA1C6F7394B6E3BE3E2AA7F6D522F982D2C77AE17C584DB8557EA34C77A6460DFDE65E541B65D095786B3EEBCB9CD58A05E615E8D5190DA40A