Type
CONTRACT
Validation date
2023-12-01 16:35:03 UTC
Fee
0.21294497 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: 0x000045EF655A0015C0746F2A6A13E14778DF5954FF4F7EFCCD15E1AE3B67CFB9E54C, amount: 112
  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: 0x000045EF655A0015C0746F2A6A13E14778DF5954FF4F7EFCCD15E1AE3B67CFB9E54C, amount: 112
  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: 111.664
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.336

    Contract.set_code next_code
  end

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

    657C560DBB3C15434945BA405AED639457C21F5CB78AC6EE59F0BCFA8C84C1DA2AAE348BDE27B16AECB5A7C638C5BC39153C07527DE17FD447528B7B

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C0CE12F78547D4888918125E0F747017C31B0A74F95EC59FAE88F44232E78304

Previous signature

A4ECD63864DDBF65D9096634C1A9FE7EB1C8323A6C6A6BA024728DCE8A428C4AAB8FB1CF11F91C5F8C0BE0A8700BAC14DBB63DCEB9E200C15E47163CB29FCD06

Origin signature

304502210095EA8BF21F183C2198E1BD454B084339DF5E45D83849C2D9A6281A002DBD8E27022055F35E4DEED2362052B4AA07E03BB4183337ED57DA67671E821610A1FBDB0065

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00989C5C22EF0A87C557B9DB064C1BB0C54CD96B20B87C1AB089FB4F8FDA7850F7

Coordinator signature

4F90607E088859DA467679A051FB8EECB1DA9E8696FB8656FBE1A040F6D59E6D2B0166990A8479FE80CB81ED69AAEE342CBEA0F39D1D96E2196D3A71BC6EA107

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

5E6F5C812EE46A07A3C79D0C3BDB4C1709D3B6F70D99EA7D8EF0D6B800B1558338CC6AA9B671336446C1D9A2C2F2E01E5FD10F387E1A8B90D311E7A94144AE07

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

1D649ADA6F370877B537B5EE99DA01B24D0AD924AB7F0D47C1D1DCDF2A4A4B5250AFAA0C088951B625CFCD7E8DF72E5D74E160E9B3F6B53B8EE4FF788DC3E207