Type
CONTRACT
Validation date
2023-12-07 07:14:22 UTC
Fee
0.20358581 UCO

Code (822 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: 0x0000854662F2FF47226AF328EFCE8A16A518F2F9F0225DE5CF5FE431071217474BB9, amount: 4.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: 0x0000854662F2FF47226AF328EFCE8A16A518F2F9F0225DE5CF5FE431071217474BB9, amount: 4.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.4865
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0135

    Contract.set_code next_code
  end

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

    01F851C788EB1997B12AA6BBBA1CC100B364006B8061F80CD19A025E1860FD205021A43160FC9D14F428413EFDE00EBA096B79A5F1C5D292161F74B6

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001AAABE313E00C82EFDCB206992F90D67779DFEE697CBC82300D230A0989927D46

Previous signature

8BBCE1C71CC9872E2EF5916640C1C3E2423246ABC6DF7F0C2B42BC6BD60032379F9320C01D92144855F67512F0D7C4F507F559D3EAAD1975AEDB10342CE5420A

Origin signature

30450221008CC8853C7114CDDE551CF91C5B8F55F0A3BDC7222D94ABD1B08617BC4D14F0920220361E49103761DA658DD14EF42F3B848EBEE64913BC4196E86F36954BA699CF59

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006ABD4EB0873DA39C2934AD956CBD70760B678C78C7B78E29F729B5D5869669B5

Coordinator signature

8DDBFD87203B048426C772D20EAF11E49C1579CD18CE2FAD15B5E96EC366617A0F5E442A12D55D57F3F7FB1B45726D40C6A96991EF18C107424CDBBABD5ABF04

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

F8431DE7B34CA50FB3A7384D7217B013A3714085D9B6EBDA19018A2E5EE3882CB4B5C37ECB6D3651B781931CDF0853C498CFA30AB6055272FE13EFE4D2BF7D04

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

4EC146AE6603BCE80966DD0C167B7D404E7E24256B7FB10348E2EDCBD08EA943ACBF96A8C4C02AF78A3712C1EE8C7AB6E7C295AD550AC274EE3392E761301805