Type
CONTRACT
Validation date
2024-01-04 21:28:17 UTC
Fee
0.20142737 UCO

Code (818 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: 0x00000728082646346C9BF3676ED7E29407BC1D2073286F694CB4E783ED9817552E80, amount: 5
  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: 0x00000728082646346C9BF3676ED7E29407BC1D2073286F694CB4E783ED9817552E80, amount: 5
  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: 4.985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015

    Contract.set_code next_code
  end

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

    FE4DAEF8EC809EA6E82D7F9F03FAC103AD87A7EAB9B665DDF394AC56E30F670AA893AF2EF9D44053B13787DDE373DEB9153D6AF8942F1BD473F43446

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00012BABAC9D54DDC917D8951AAC227508B503E4E7BE3B729ED49C90381051D0DD91

Previous signature

74F027EEA59EE7AE408E39FF3C5CC7B70F2447A30AC7FA7DADB492B36CD8C5A0ED6F6B27954525C2F7F063EA469843B396EE2F460E70EEFB5B3DF8C1F51EDC02

Origin signature

304402203D85C426BB8B54BC876F8C87D6FF6F44F5423FABCA85B89F34AF4765E9E11417022017D5CD9B4EEEDD352CB2DDCD2B4AA700D07CA3B5A14DCAC856E07593A1093943

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00C55B51BABD2D91C3EDEB6E0FFF801CC6725D952A8AC2B38EA6F1639B577696E8

Coordinator signature

ECE3B7CB5D8ED69CF7672196EC20E6173D9499C2608F0256BD64E389CBFF98C0EC2852F77D28BD5B831B19D01BEFA53CE395DA6DA5C1C403906CC1E6FA86000C

Validator #1 public key

000103E30584AD8DE66F9E29419D5D0ABEE5A76722C9FD0D012BDDE3A6E2B149C48D

Validator #1 signature

102B7958ADF881DBB8ECDA07CD2EDB187DC668C26095B6DF041DC1F16E6294E2F9EE0C3A53B185F2B6738380A125C944527F1EC3B206F686CDAF3B3B0809050D

Validator #2 public key

0001B01EEF96BA7E95FC844D456CE8868F18864519FC9532E1751C2035FD044DD5D0

Validator #2 signature

CBC051088CBEED8FECEA4E1875E8B3C5CBEB3BD55CF3E7B15E4C985192002710E96542156FA93744B694F5247897F5861AC85ED82177E024CB03833402F9470A