Type
CONTRACT
Validation date
2023-11-08 14:23:43 UTC
Fee
0.1803811 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 10
  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: 10
  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.97
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03

    Contract.set_code next_code
  end

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

    8DEBD2045C8F51456E94E027892F7B960B732FBA6AC959488676FEE90C9DE3F3F21D119895FB2187341DC97DA77E2E46CF2B052E68DF305FAE5E3FE4

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00011B3339A5A4D128D24C09A7AECDC87D22CC20BE92E1F6F0F94730B113BB2F1DA8

Previous signature

D5FBB4314E5F07AFA25B7F756DC2DF6E8B89E39026A763983FC5B9BB56D8BC4DE63FB60FE5BA8EF25E06951EA63340399AEB49800842FBE3B73EFA0B90F68A08

Origin signature

304402201DB9E1DD903C208CC3ED8AC7555532FF7614E2511FB78785910694D00276B2EE0220509E339961FD23C5DF2A18CEC7A1E8EB948FECFA5BC7429071DEE15805F4AC5E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001EE22D12031DFC36DD226E8E14D16A8911B1D96E6598C39D07F5F40DA1B818CD

Coordinator signature

6A315572ECD28148BA9695A14A3140FCEBB35EA3980E3B35960BA1AAA722357ABE3A373F5FC08A30B8E58DB963B435A22DBA645F2EBBA1BC0BDCC3A417F52D0C

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

0DFF489BFFF5D7AE2805816F778BE5B62CB029456D7CAEB8F61E4D471826A288CF7CE5376C7FEDCBB76485DCDD675A39EADA2D3B54DF0BB6B7A8F1F17B578D07

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

999FCE1FB0A17B223796166198F0A2B144BCF6C8D531B65F1D7C4342F9E42C6207D469FDA430A757FA5956FF97F93EA7D169BC63306BF643BBB6D0309407B005