Type
CONTRACT
Validation date
2023-12-28 16:16:06 UTC
Fee
0.20543269 UCO

Code (821 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: 4
  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: 4
  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: 3.988
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.012

    Contract.set_code next_code
  end

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

    1424F9439FBF58C132D5CE95E011B0576F67409829F8A24983F882D29E2CBF4FDE6CF3D0DE30F255B1B36CD49E7029BCEE9555958F6733CF62268E87

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001E777625E41627FD51508FBAAD6D72BDFCD336339C5F57C6B45956D8FCF782B2A

Previous signature

97456CACD814448F0A342402D99035146C7F715C90A1534232E0831923B779BF80FC747FABE2D236B62E42D96C4854F019399063D12C42DB9DF5E2D03C13FF0A

Origin signature

30450221008E055CBE9CBF7FEF8237DC5BB28BCC212BF967FB001FC0608B6E47C8C3E560C5022005B65171B800A775F6C6E7523678BD78038B425CBED1FBF65EA070E567BB5911

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00B11EA94318EF806C9B3DAEA09D034F461DD728C2B3EC97E61C899AFFCB37D788

Coordinator signature

0450D14F8680D00D139BBB709CC1BBBB65DCB01CF51C726A897CBB564093E934C20D640D7FAA308055BD334F431B05FEFC7C4007CC74AE16AC0085DD50678405

Validator #1 public key

000162E6ADFF9FBBBC4BDBB3CD56A5A13A1E8576C3619ADC58A189F7E9A3A77FF95D

Validator #1 signature

E215213DDC67702646EF7805EAC70ECE09C4543E813DF90BDFBBB4AA746E866CB8667504DB1012BF37F5A3C9C949F89905CEF4A55CDE6ABED0B8B6F96C283F06

Validator #2 public key

00010F2A0E4C424582A94BD90E05FE6931628F91988ABBE387D365994F1F3FCF5A12

Validator #2 signature

674CD26167C81DE701691C76658414EC7A5563EFB7E6A25F4DB31D4B5A6A1B4E4F7EDF31F58C35D9EBD4756A94BA894CD8DE0D36EA35CAE14B3F24A74FB2F903