Type
CONTRACT
Validation date
2023-11-30 18:29:05 UTC
Fee
0 UCO

Code (869 B)

@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1701376080 do
  Contract.set_type "transfer"
# Send back the token to the user address
Contract.add_uco_transfer to: 0x000087EAA67B7F82452DA9BEC9A80FAB2F43D8A5E4966085ACBCDDA89B939F039AF1, amount: 50
Contract.set_code ""

end

condition triggered_by: transaction, on: refund(), as: [
  timestamp: timestamp >= 1701376080
]

actions triggered_by: transaction, on: refund() do
  Contract.set_type "transfer"
# Send back the token to the user address
Contract.add_uco_transfer to: 0x000087EAA67B7F82452DA9BEC9A80FAB2F43D8A5E4966085ACBCDDA89B939F039AF1, amount: 50
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 < 1701376080,
  content: Crypto.hash(String.to_hex(secret)) == 0xA8237B045014662D248E145B29E8AF6C12FCC32CEB58DA256B523892ED03A741
]

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: 49.85
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15

  Contract.set_code next_code
end

export fun get_htlc_data() do
  [
    amount: 49.85,
    end_time: 1701376080,
    secret_hash: 0xA8237B045014662D248E145B29E8AF6C12FCC32CEB58DA256B523892ED03A741,
    secret_hash_signature: [
      r: 0xA5B67C23426C2F1B7095A92C7DE64089426C59FA49CD93D25F9710743AC1CAD5,
      s: 0x7FED8266CA885EF6DDA8E476083C7E40FAF51833C9D08EB6D18FCF320CD03F70,
      v: 28
    ]
  ]
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    A15F70100F50098CA3EBE314D6A556161F2C7F3CFF8E51B239BF7BF393996EF0B6790000ADBFB292304EC64FA7EF38E28343085A5637FC60BD93C294

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000183329622462FAB31652B7ECE53D5E0337C9BA7FE60041B8885BDFA03960A9F5A

Previous signature

0F778B12228D43EE3063E3020F9E47D9C30A21E73FE281F6A29EC90F3A975464214188A068B68E65BAA2B556E1643C1CA4795FADA46CC0AFC7E05534D46A080A

Origin signature

30440220442F0D245BEA6526D233653EE58649B44F7957E3EC1AA24A8C800D16B5E9B86E02203253531EEBE8D22ABB9E7A1A62ACF4FE23D28C810C8327D78A78BD0B27819D34

Proof of work

010204AA023E1E039788AD4B8F713C8871CA39A177414A99A0788993AD725B1FBB7AD5E4CAC86151A9E03451DCACB1EFC100B1E450FCEDAF5E5005F3A4C503D1D29712

Proof of integrity

0096520AAF4BB7EA1D7E926320EE4050D0084002358F398F708DE67DD3A07113C8

Coordinator signature

E4B5ED7A2C654A894061E2EF12DB69EB2323AB246300C75D1C313EEB05C6CDB162B105E6B0E3C8EBB1EC5959B5E51A35591C6D56E7C4DABA03F28B598737CD0B

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

3D0C37105DDCF6F1C3C17CAC320EDB978AA38AD1DE71A6DF764EF9FADDD93B63DE63726327C712541E42AE612290DE7D8A23143A0D10FDCA7C4529561B541105

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

D4B5E04BBA315FB21E4F4A8D4F33A30AD6D763907599943CD0535312CEBF4175055989A5D7E3258A095DD13FF0A3B38DF2A0F23D38CAA183619C8E7A1645EE02