Type
CONTRACT
Validation date
2023-10-24 06:45:58 UTC
Fee
0.31921322 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: 0x00007300EFBD6F864648D3275C4A6AA0B1EF91D276C9F5D62DA49D03B8093C530F29, amount: 1
  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: 0x00007300EFBD6F864648D3275C4A6AA0B1EF91D276C9F5D62DA49D03B8093C530F29, amount: 1
  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.997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.003

    Contract.set_code next_code
  end

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

    3EE82EE2BA48344AF3E31F9FEED067726747E73332E69C4637BD0C17F5EE25A3A2C36D14AB1857D4D27D77E612E8316C7343ACD47D118ADFD55358E3

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C88EBEC2B99B79E0CBC1835FB021D62953245FE3153D68964F4FA8ADED152793

Previous signature

ED150621944B1738F9D3DC5CE323B5903FB80F0680CD984FDF7C604134B3430EDF6E171B2B1C20544499E8430FD04C353911ABD8D1CEE140F2A4E6D4D3C9DE0C

Origin signature

3045022100D5D7CAE9B76E71756ED268088FE9BF803C64EC42B1BE9417F319DA3EB0B86B7F022077B42CD54DC5A68813DAF864A6F79504FF69D2BC3CCAD0F8E109D9033D156485

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00374328F48FB797AE1394A69FFD535FBBD4098661BBC292472AED78933E77CCD5

Coordinator signature

FEF7F827F4FBEB8449F4BDB3F91205662CB0CB4CEDB4B4DFE070E15640D33A67AC318E40DBCF465F8B1553E59C268B71EE6215FCF45C3F35FA792560C1BFA70A

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

A68B21BA712F5F221F58FC4038B346D4376A0B04AA9001C2857B673F4F7C2F9A45E4DA12DE9D5EDC660B6D363540025946D44D65A339872480B1B515F57A000E

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

B5187D32D8F69F5E05005B80A7BFECB952348D6E6290B0649C64496C1A59A1E74DCFCB15E2ECA6899A107217B8C3DF063CF0112BB81D3D29926DB030C4DA9E0C