Type
CONTRACT
Validation date
2023-12-10 12:35:24 UTC
Fee
0.21475057 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: 0x00005F4C53E037645214F5C85A044BC2604168E36EB4493FB422E60E187E5CAC66C0, amount: 75
  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: 0x00005F4C53E037645214F5C85A044BC2604168E36EB4493FB422E60E187E5CAC66C0, amount: 75
  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: 74.775
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.225

    Contract.set_code next_code
  end

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

    15A83FA41244C02A240C93B217047FB8DED54834A00695354E202F94C352EEB066808DDC03EC66C4C2E0BBDDFD2FED981209C5A106B06DCF35F5E796

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001EAE8EF26D51A4852B4CC41CD416BDEDD217B44676FFF128550D80E84A7E4B081

Previous signature

1F8E3B39B97404A7FC0925EDBD41A448C3743EB8A2F0A6BCA4AE0980479317E0863EDF953D37E7F3D2216B262D6AB83E16075A37F9416FB73283899D656D9A0A

Origin signature

30440220665ABCE936E2E31DAFE9FDE3BE81D1D26BAE011D14FA7D8ABE93A7962FE89ABC02206D6A1FA1EB1CF0FB05345F8330B443BFED56F5301DFE03782869CC3AD42D954F

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00AFEABD4EA042D2DDC053568035F0586A20D472C2F2990DEC522137292631C12E

Coordinator signature

0D48E730F65C8E62B320D1A8C6BC9B1EB36C284A152DCF72E58A2FDAD1E7197197F281BEC67DE60AD0B802F8F8C4B06F3F799422A16DF91730E525E13E74A40D

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

019E03CCEE8509374ADE07ADA70764A0AC80470F01A7992AD980FCE95D2A19E7E7B06C14ADC275986442B0FD02502AC302AF9CC4CADCAD3BC499FD4A058D170B

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

38CD06DC95EE940B901514F5278B6ECC2FFDCF3225ED40A98586BE238EF44DFA75A786FD1D44C1EE2A9FDD69719A80F505692D0E43FF2A9B283462C32FE86302