Type
CONTRACT
Validation date
2023-10-23 15:22:27 UTC
Fee
0.31014246 UCO

Code (887 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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]

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_token_transfer to: 0x0000CB30ACA5320066B4413E9D4190EA13562F3225BB5F49A975ABD91CFFDAFED88D, amount: 0.01, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
  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_token_transfer to: 0x0000CB30ACA5320066B4413E9D4190EA13562F3225BB5F49A975ABD91CFFDAFED88D, amount: 0.01, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
  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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
  ),
    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_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00997, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
    Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-5, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1

    Contract.set_code next_code
  end

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

    6FB8C9B42405FBE5F7BD3306A25EB740EFF2CEDAFE8BC4709BF230453434B55A9C32A9F9FBA7027AC52C7AFE94ABE8C362F17E86FEB17759813752A0

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000106F8DD30970D929759A9F1C8722FB9F6000884454004C3E5D7C3C51812383E80

Previous signature

750044F853B48BF5A15ED7B9D0FE7EABD7DA917CCB4C5DC87947629EF99F1293090AE557901022F7ED3F3C05EDBA138654F97949A00B950DFB9A79167E4D1C06

Origin signature

304402201863C13592AA0BACEB57E04E57CF9D4334D3175E6163E3A0C69FF682BD65EBCD022077EE649C2117AFAB412BE1B6275C8E504804BE06EEE6020F45FEF9190E31B97A

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0048822F03560BE64AFD6BAC2F5563C8FC46631F4601EA3308BE09A6694223808B

Coordinator signature

4A2015E243B518F2F0905339E7103DF16FFC031E2F4E5DC654D1C84A6C5D985EBAD43A6D32F50486CB3FBEFF815DAD7D90EFF3D68E98DE3A541D56639E5B8908

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

D775CACD2E00375F19FED3FAD21B18AAE672F0BB25601A3035E5E2658A9394538B1B5C951879DE5C1BC22077CCC598B9173C8903ECF1AE771DF5D003B2A36E0A

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

523DD791344C5B1F824D7B8FB1BD1CE886416E9C7207F290B4124B568534973D9440A56852777CF60028FB378E026AAEBFFAD872A373136BCD35207110A8D90B