Type
CONTRACT
Validation date
2023-10-20 10:05:47 UTC
Fee
0.25045222 UCO

Code (824 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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.001
  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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.001
  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: 9.97e-4
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-6

    Contract.set_code next_code
  end

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

    9069B69A5AD4C8C14046972477C04CCA3D788FCD60143180F4FE372799FE8E16A7B7589692657320FD55723A7F2EFF2FB3B5BF8979B6C276558FB801

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001A8E618196875B8FC00A3476CBFA17D33354F0E649285E2B380174A8A04657A52

Previous signature

B10D13CEDA7693CB09A9084A272DA81B611AC4738EF61CD5DD386CE1FADB184662F8709958EA91AD66275ADFD54C9AE9E090D5E4B595A7B60331895AD8C2F402

Origin signature

3045022100C8518EA331D7B9AE3B184EF6EE1B0CC935FA302157044C9B9695640782263C6102204E38C666BC1D654AEDED43DA129812BC1E9DE42E0033A34E5190538569F3E437

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0017023CB5ED91E727319ECA628AB2B557E09DA369B994D68B47A63896CD74BBAB

Coordinator signature

0D6C2C4FF91DD3DD9A67D3E5D689B3D5ACBD3397125CE725AAF9FA22E187FCFE16B15F291E888E9BE837CFAE57AA0F94B20B6448B8C206FC6190EBB1B5027E00

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

4AC2BEE2FDADA11BEA7E7D5963ECAFA58E1B9BC7329F05AA06F64159A56049FA7F1401F4218C94951CD1697AAA98EE8B569B7704616E2354EF45B49F5D914209

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

54B983C83B1A35927ED0E5C7D3195C68959682A3B9E8EE7EE03B3F90F4A8815AAD20551F4E3A342DD6DF4505AC42A6B209C8119FA5F8EA7736D8F393E4B23B0D