Type
CONTRACT
Validation date
2023-10-24 14:50:39 UTC
Fee
0.31288496 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: 0x00009E731DE71C9598A6C853EA89C736B1DAC3652AE00753651B642536AB14821F06, amount: 0.1
  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: 0x00009E731DE71C9598A6C853EA89C736B1DAC3652AE00753651B642536AB14821F06, amount: 0.1
  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: 0.0997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0003

    Contract.set_code next_code
  end

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

    34703BBFFE66AD75AE4300F83D0838280BEAAFF4627F5E958E9965B37934A77C5FE3E0B9E67E672B455873506F10E90938E8950FC860A77A2471C693

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00014EC14CE92F6436A1C7BE358F7D33D1D2378CF9AD3F1A8927ACBED61150FD9A58

Previous signature

42B8C6EA9C477495A143CE37D704B74F14F5E7E1AC88BBADE339D79018C1C81AA53F3288751D9793DEEA963861FB0E0321DCCFA84E0BEBA0FAAE9B4E7E2BAF0E

Origin signature

304402206D569A85140E42ADDB09A211B4D637B42CDB33C4390D50F7B4D7913E0A3EBDCD02201D6861719EAB44F427F3DB992765D18007F2294CC852307A94B7EDC9D701B523

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00CA95BDA679F7C7F1DED3D290CF62AFB84122400D6788053AC35998315AF30B3C

Coordinator signature

A834DE5867C89D60A21DEA80A68B4A7F8144E1A0365B7F66223CAD200BC023B5C431EA2D1F100DF64E8E6449787A8B880389099F57FF9862547F33B78BB8A006

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

2E568BB440CE226A8C8E5537D5AA8AE5C6688C0E46FCBBB58F5145E6305FE0EF36776C436C1EC8DFA134B7A924EDFF1F94E494424509944BB242F192FE47FC00

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

AFAF780BE9ED60934C37C975C65600B776B92F5885E3304A3EE49B1D57929AA55119A53A7E9E70CF0FE171CA6179F9606C2B07B6F6098C898133B4CCAB63250B