Type
CONTRACT
Validation date
2023-11-21 16:24:24 UTC
Fee
0.19002756 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: 0x0000647409F94DE9798EA91E049B9AABA07B8CF3570A22056513B3437091C04B6807, 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: 0x0000647409F94DE9798EA91E049B9AABA07B8CF3570A22056513B3437091C04B6807, 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

    EE523A65A6F7D7A0D3747E2E3E9E2E7763BBDA64D9B0E16893D3F6E59B7DDF7C3D89A623960DFCAE4077EF629822E9978E4722B8AF6E7A2A7AB83C9F

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00016ADDA9FC6D1479185852592534195BC2B05A581A308710B2B21A846C7709DB79

Previous signature

ECE079583ABB3C258A7E0CF1885A8DDB76B2C16BE4681CE7AA3D3D34DD77FE655E8FDE95B9CABAFAEE9C7B0B244FC0A5AA8249E9F9993D9027AE577719371D01

Origin signature

304402204D75768C77CF0E92D5246D809DCCDE37151AA42082340CFF7B44B93AF66DF49A02202FD9EF1B3A60C0F72F79B9D3D417D4E4A8F70030C56826AE776F51D0B58BD4CA

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0081A3981E72E909E046B689E5648931E7D8B80E585EE01CCEB2CBA975AA6809FA

Coordinator signature

9A260F30889C1739784BED80383BBB2E3207AD78A9CD20728153911316A4944DE25776F199FD9E60F888062BB6A19CA5F5016FC741267A5E917B285FCFE20300

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

91B54A3A35B02F63C30F3D81B08954435716DA71F7718B5680E0FE6A137B8AE160F086604E3322D4FF4E6465C2524BE695EED7F9A5D448CBFFF0D87B47A86401

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

986C218D3751B3E257AD50CA51755932DDBE147DE650AB2F8384823919E6F5EA4ED1AD50EE144A79446941CF199837E6C444F177D7FA79028A58ABF4DC96D001