Type
CONTRACT
Validation date
2023-10-20 08:18:25 UTC
Fee
0.25321304 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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.3
  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.3
  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: 0.2991
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0009

    Contract.set_code next_code
  end

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

    8188FF31272D862C529E2474A139C6E91E1C041229E913B4C341B29FB7B0E7E453A2359EE0D41B950FAD7AFD49CD276603312C238B01DC12318EDE48

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001BA87CFED7D739F5BCB19F225764B219B1016CE087B1BA922440E700DDCB7076D

Previous signature

7A1543D665A5188C220A144410AC950B2922FD16A3357AA432DBA45130FB62E2236486E878848C465A5D830BF7B9BA07E7F7686844471841380FE862CB795409

Origin signature

3045022100E3F6B1DA6A15379C5C20FF33C7EDDD7DD1E9BF457706C7EFB66CCFBA8FA9A38E022007D043D1A7955A747C7B14C8EE883E356B8236C2AC52DF064C85BA14C30F3F12

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0054D52AF3B13D30906AFCC1A5225A70323C845EE641BE8FBC8FDF5447DA94A888

Coordinator signature

BE8A4893513C05C0E4401CBBC81884765775C46F5A01CD88575D2E78534815CCE47EA8ECDBC51981E7480588C3619ADC28D74367B8CCDD930E0C45FB37CD570B

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

1B742B5B79E50E56EAE5381E9EA4CBCEECC3EED7AADB13235920E1A6D604506645B082F7D933BC2B4EC60891E012AAF3A2DA654E9D9D5122A94A76651260AB03

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

BF196C774F78531E610375C7F94EC13C08B43455BEE6946D33852A253D038897C1084DD376C1792C41D89BF4F235E7884A9B5604F54499CD5FB8B5F934B4AA04