Type
CONTRACT
Validation date
2023-10-19 21:26:04 UTC
Fee
0.2502614 UCO

Code (818 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.5
  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.5
  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.4985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0015

    Contract.set_code next_code
  end

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

    9F806D0281E14E29F3AD2344014A018E18F47D7D4E8221C30A05CE417C35498BAE7BF1BCC7312DF93A849B4FE8D2B374984A41F1A6B1E1AD65B9C7DA

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000157CD85A020110FFE586052AEC592852FADD56BBBE2BA3DD7BE73C168E961F3FD

Previous signature

24F1E835B877FAADC9CC5F0E161872BE18E97BFA76069BFBF19C71D3C1BFDEE5E39A9337D0E77F0DFD4848AB09A3A95C395BEC3477FB4E2131ADA9D9BB44620A

Origin signature

304402207C0FD899416F276FFFF3A94D8ED0E41DEEE6E21F567621037FD32B6D252A77D402203F06757903F1BA829453BC4438D2A67509DC7AB6B976DA6523C3655F7D30513E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00EC1F96B13D91BC3A8C374A33A7B4AE8F9E2595E05FEC6D387486CC19FE5EB9A1

Coordinator signature

A57CB699286BCD379881E31C67EACBC92B49CAFCF6CFFBA5455D17100A3EBA17A8716C0BB093F0888B6628237FD965C1CECE854067FF29E502D86FAC95A9A80B

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

3C7DD2D290C13CCF667BECABF25F3AD1D2B756A8A61A25316C47C7AF09B6DF5F6E3D2C1C6DC8818448B3ABA2BC919CEC2CC44A4BCB3F02B690CD075FD310B304

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

20F5EED56FAD2446136FF14B17E2DB02F16B29E4FCCC7DFCCD0E76E858A79EBC482E221ED6EEB53BD1BEC95C20F7A5E2CCB3DFC8FF8BFEF91CFF5A6B0431640F