Type
CONTRACT
Validation date
2023-10-30 08:39:20 UTC
Fee
0.28271137 UCO

Code (794 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 1.0e-8
  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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 1.0e-8
  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: 1.0e-8
    # Transfer fee is less than the minimum decimals

    Contract.set_code next_code
  end

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

    90C0C026E25E25286B671F63FD1553AD7FC9A0C868E9F57D3E5C889D61F17C34B8E52C27CFC320FAAF3859FB2E4FA56C1BDEF9199E9C21F433CAB515

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001E4C04FB64AF611017B4BDD9FD5FEB65381419504D182D6227A5B5DCB7EB3903E

Previous signature

F9F42B0964EDA65445933D0996DFB96AF1D21C670FEA0D49801533C29692C1B8303D609C99278BFF814FD02C420E85DE2A1FAD2936AE10BAC404BDAC158AB609

Origin signature

3045022100959DEF12232AD093C2F1B26E77D825F7C376B03F9A7866C1527A6A5F05719A250220084478745FEA9CE3FBFB8B8A86A2E44A6607C6C8295F7027434998B3FB264AB1

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00DFDFF377399B442954E33EE9C5DA5C83630F3DD65737CDC8DD016AFEE2A698AF

Coordinator signature

3F053508D89C4207C9A4A75D2BA6D172321ED315D2AE9AD286E7404E976B3A188369A229A82A81E341EB2BEA8A9455F79FA463894C60F7FCA6BF305D7A275F0E

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

A3A8F18D5496F67A42D914A52E11F993CF3536187C5E4D123B2E58DA7F77C2DDDF12AE9F44BEE39AAEE686562BE4EF039B6DCD19396F74BE8329AE8A0BE41405

Validator #2 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #2 signature

1639E6AA50A25BCAB614E3BFBE196F8E4366A02E65595296BBD3FDEEC258E27930493B5BA505F082A78D093939D982797601F3025C9A5353947EF8B7BF89BD01