Type
CONTRACT
Validation date
2023-10-20 09:38:38 UTC
Fee
0.25082575 UCO

Code (824 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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.001
  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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.001
  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: 9.97e-4
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-6

    Contract.set_code next_code
  end

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

    6CA1E9ADEF4A878728126380453F437878AC429BCAB6BB6EE564ABDA474FC12DB4C959ABA6F8C3B6BBEDF055AC2E6730EC0A8F4331A5C9382AC777BA

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001FED22ED69D649876C80222FDD285C7995E31944917118D1409057B0BD7735CC3

Previous signature

A81BFCA30D8989B20B82D4DAE604170ABD3E80ACE3478928917AAE57D4B6A0D81E90401DAAD026736D49CD30D98226E6D16674DE6AC6D5FDE1F65E4C55FF9505

Origin signature

304402204EC22E26E7F13013E6557020C0B326DC4C852826A7C80BF3FAF67FF17827426602207C2D9CCC52E8E3166B66048EEE6B81F724AC84299229BFB1BB1FC4EBBAED2C37

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0001F12CB66F8512881E5EFACE0D1D52924CBDA66FFED73C165428A572220FD936

Coordinator signature

0E2BE83D3A3A28DF90C1B21B81B32AFAB5DF8840D65ADA14A2FA86BDE1D3CF129160DB0D5A0E559897FD505FA6F37EF4ACE337F5936A7241F4BC07F76ECDA30A

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

CECAD439D529BD8A9FA316776E217B7F1F238F678F91B19B807AA30FE751DF1FCB33FCA8ADFE556B4F368A97B9A4FB159886491CEF14BEF24AA0BBD1ED489500

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

DAF0F92331C838313C6D6476F3D0D9AC364856A6DE18F1A0AFE8D2BBD4EE9F820321D421625405ADF181161D79AEC1C7767E68A6B9EE9453CFCF8801F0ED1E0B