Type
CONTRACT
Validation date
2023-12-28 20:31:51 UTC
Fee
0.20076195 UCO

Code (819 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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 2
  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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 2
  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.994
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006

    Contract.set_code next_code
  end

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

    26B8B296BFFB04E464EE86AA2E8E34D232C3FBB5A2711FA49C376E6AC203330A683FC18D70DD52E6FFAF1DA119870B5BA6AFAE3807BB0587C3BC9BA9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00015D9EB4629A14B27F5A178FD1B40E45B62D9C6CE2AF1EEFE32F8D8E3329AA7BD3

Previous signature

1D077F38DE590B1B4918F7FD041A9B6F792055B07D27F385B7159AE451C720E84598A77B1A612BCBFED6F9799303A1C1DC8424279975BD807E05C88A53EA000A

Origin signature

30440220575D3D011F53C86614D7068B5D5A119FEE9BCE34658A4002212FC42F0829B97702200F6691BA1687F9EF494BF063DD73FF2D3DFC9277264C04DC150CE1B60F4D5DDE

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006E6A5BFAC3018DBF15BC7E576C321FCC0FA155F759EC38638D867ABA6256942F

Coordinator signature

029661BD18E6061C964E71AC1D10FBB8C76C921CCD22C4C7B7E8E5FFD35FCDEDDBC2A16DFE4B30D7EBB8DD0D3E50B1F36017D6E967F54CAEFCDF312F8099890D

Validator #1 public key

000134772A943DC0F7038B1BABA39E18841C12DD6682B1B6D1D15E08D7CAF5339AB0

Validator #1 signature

196D44A36D680F68F8E895E62C567A519340536D40156900782876D5AFBA90DFFB620C043179A3D9E44C936E8B47DEFCAFC78BE5FEECAA5190244C6982E28E05

Validator #2 public key

000177BA744AC778DC2D51A1B7C622E7AC4BD1E1AA8DA2D0FCE71BAAB7DAD0E020E0

Validator #2 signature

17FB7EC0DD404BE7D0EF7955747D0EA53C11FBCBDB0C63DDF5FE2025803BC05E548329AACD3D20F463D6B434A1C43DEB32C4C54DC9CDDB579AE6349D8CB6110D