Type
CONTRACT
Validation date
2023-11-12 20:32:55 UTC
Fee
0.17509359 UCO

Code (821 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 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: 4.985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015

    Contract.set_code next_code
  end

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

    1EBE80848DB52AC78A7D547289F8ED59DEE0F3BF8648A1A12649BE55A8675E9033B2D07C520340A9C5D330909F7EB2B094C9BE4507DC4F2F7532FB89

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019FB5CC5D71C16BC6C03FF80464C4153702FF7B67F7EC32C1EAA0E051F96BA506

Previous signature

572FEEB1BC81BB8CCA26005DDE7C70B197A44995B5276E0B61AF96571D56B9C81990E92BD7720FBC6547E7B726FBD8AD90BFCAD0E7CC3C2B765ACEDE962B8A07

Origin signature

3045022100ECA7BB4895844D82FFF3700E5E85AB8191FAADCF97B0AACCD9A785FD98A7BFB0022078A71F0E51E3149CA2FF0D2C3048EC34458EFCC42F1843393C409657463B1BBF

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0045DBC39EB6762544C44B3370A62BF9D3AAAC1B4B8D802DF49D3CE02890A09642

Coordinator signature

4BB1BA04FC8FE49F2BCD84098C8C8751E412140EC2FA8D70F516A6475898D4CD2D0249CCC328FBA2531F105B300EF7EF8C604B8C7836089B4A4C3E3BF4E4A802

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

0547A1CEB6B371AAA8330CFD5BF47295A64D8DCA6FE2FE77AAF01A629B9B5083F2E6497828BF8263EB4F376884EACE7C86FF1792E196660D1CD4EF863D6C5605

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

FE3A93000D9E31F76483E4958636D6A635697DEE3D403FD27EA72A9E0B675C3AF4175A755C245A35E6DC1BBF2BD422F4734DB9700E941C06CDB755CFCC81D20E