Type
CONTRACT
Validation date
2023-10-30 15:37:22 UTC
Fee
0.27788138 UCO

Code (817 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: 0x00001C6353CF7015A1BEB7096B1ADE63CB30508CBDF143A84818B53029BA13910199, amount: 1
  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: 0x00001C6353CF7015A1BEB7096B1ADE63CB30508CBDF143A84818B53029BA13910199, amount: 1
  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: 0.997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.003

    Contract.set_code next_code
  end

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

    A318CEC6C5F7F9CF2FEC2BEACE329359BFF0561C28A706D66B45589AA8E8C466A07D9DB069DE24C2343AFBEEE68EFDF5F6FCA3A649BE1658ACBAB3F8

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00011672B1B4458F72039DBF7798E01DBFE3636FB56AFB808AE44273B3524AF1FFC8

Previous signature

CA2514D953CD87553683F00E5E4054BD6C583E76593A815FA9BAD7DED78AF338DC83C76693218E7C54BC23097EFDDF8F86C5A79EC1864A5214CC3509B0CA8B0C

Origin signature

3045022100D58F556C2E3707763B6A48667FCD91C6A0F6AAF6CA581E763B8D49A81AB3E103022057619DA4F0A0E6F94B71D2E37BDC5387FB9ECF9F07F55B1ACA848773A8E63559

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001C06F9D262B3AF788A3C591415B916B694A566679F2EAE52A5937C9D4ACF478E

Coordinator signature

D42D31AE30C6669B02A21A6FDDCE5B38F844CFD851A79DB20A4B05E3FF42D51FE672B7D017229417FC23EFEEA7C3AB93A541956774EF7AB43B0F03C776D09109

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

69BED1BD835B4AB6B6740ABBEB9DBA9CE4F0AAF3B18575BFFA25B10A6EAA0CC78692E2E55CC8B9F80D7B0AB937B784358912E96BA3D722EDDFC7B2DEC5C42106

Validator #2 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #2 signature

7766C46F10594DBE3A56FA0760AE473E26A183753F1E4DFD4FF604BF4D0ABF03BEACD40ED168A1BB75B06ED3C339A5D3C95438324835484A76C582DFA4BF4E09