Type
CONTRACT
Validation date
2023-12-14 04:57:13 UTC
Fee
0.21855743 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: 0x000086EB3385DB2973C88571098ACC1333C44FE6A936D1E105A0A8AA776509233764, amount: 6
  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: 0x000086EB3385DB2973C88571098ACC1333C44FE6A936D1E105A0A8AA776509233764, amount: 6
  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: 5.982
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.018

    Contract.set_code next_code
  end

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

    83C7207C557D1794770D8168494DC3D064F362A8CA3EFF81C8A16AB39E9230DC3BA0031A2B09B7B641E1D6FDA3D7126D15D10665779444CB30B36A55

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001F249AD261830A90FE6195C9EDC2C3677615A00E121A60694ACD0FB3BF5C227A3

Previous signature

89644FD53CC0C2DEDF605A4196C7FA17F7EC983D383CE9749B5EF9993E8808E710CA62FB707ADE54787B3ECD10473B65EF060305D449D922EF5971BC2586E80A

Origin signature

304402200F99132745FCFA9A06F85A90513221C7AF507DFD12D436B4C90D41B25F07D5650220181BFB26938A030A4AD13235C8B15A023637CD4A6069DB121D40A33F1F00308C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00BB94CB08F44447BB6DB4BAF8ECA967B7E4C2708FFAAD53CD2D4D8C7C5647C569

Coordinator signature

41DB71A975F6CB931FD6F1FBCACB67A4EF4755C6DDB80E557BB1CCB1D454E93BDB71AEA81777E1AFD1BBD44D17C2C42AA17E11C3167D3A6C0AA1084EB022B50E

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

0B343F761315F8674ADCAD7288401814F4D4D44F818E0F0DE783EBAF546B444EDFEB6A351E37E43DBFA04C2D47B7D1C09EF967FD5150FEFEFB062C3E1E23F70D

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

3ADD9DAA9C4DC64294CCDED8E1E83670F0B0C2132CE3C696468D77F67D302130F5598E574862B5A0F95238F786320CEAB904A2A533A292351154F0BEC46CAC01