Type
CONTRACT
Validation date
2023-10-25 17:35:12 UTC
Fee
0.28650539 UCO

Code (826 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, 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

    BC28D11886A5F7BA9A77F6D008A3188A54C0BBA518C3ECC1B1DA130A961760CE5DDAA0280737F1E616F79714896786118FA9ACE38EFCC5CB0307BABD

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00010F49B3407F1FC8029DC05BCB0341EB8F65EF238FD442ED1AC969C7610812BAF8

Previous signature

784F7BB2E97A9F846DDC9B6AFC23CAA5A57DC9F390AD14A9807177A95C9DA37AEF11230448F8E6C1296ADCE6DE7DF95BC13467C0D093524ACE04096E188EBC07

Origin signature

3045022100824A049E9BBB2E3C046652A5E77ED2F4F2E54F7AD62E43A000F5AD1056F9B0F90220152125D7B8DCF56F23644EF829DAF635029404262859F5D9F2BC1A37A8DCD152

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0038183C9ECE830D5D0F4B130FD26F5CAC8E5CBB0D014EF426648F52FE46303E87

Coordinator signature

8C1B9D265943145F7B6AA7C0C3B775C5430372A707D947976DBE5CD7D04A44BD30947A757FCCEBDF8A894135EA9C0F00FC7D662EA6035647F50E55A444FDC20B

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

23AE8FE255FE282C1938D5EB360297C2E492E5FFAE95F4A4AE27C94364D0B007A70CE660207C405E16AFDD24164039C3DBA73B78E95C77B92692004D31E49F04

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

9EDA6A3AE143F665A5710A7B9B19DB5CE8E1A9803AC6AD7A0964BF257AB1917ECF343814E09B7646494B49B12A1015D0B2D7DF5D3CCA17F65B166091F8DBD90D