@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: 0x0000C8BDA3C290FBD6725432B394D65B8A2A1D1BB1C8A5F326D5419AB826A0C2DADB, amount: 20
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: 0x0000C8BDA3C290FBD6725432B394D65B8A2A1D1BB1C8A5F326D5419AB826A0C2DADB, amount: 20
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: 19.94
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.06
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 19.94,
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)
-
Secret shared with 1 key
Encoded secret
D8B93C8E1DC26F2433FE6C3B9987188D7471151CFC8929913FA8F4136888E4332A3DAA87A5F9062443E072AA4004790608BDBCC7F003E6CC8F47AB2E
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F68B...7FEBAt 2023-12-02 14:09:34 UTCAmount 0.4236752 UCO
Previous public key
000105F8559AA703FA6EA64FC599FEAF6FF1B94ED19C25193A2B23DB5183F00F3A4B
Previous signature
BE9353256E91C53E165D3C0992571FA77FD3D44A7A6CD6A88838CA9C042A7D2351D481791826A740318F07582E5C24A8D0FADD891C3C9C5086AC7F73E447780A
Origin signature
3045022100CEB0EBAAE4B035F67568CAE284F308E5C2DA316660D4917DA89EC5D47D48C7FC02200EFB31C2719DB6BAE2CD56D79B800AFBEAB605F7AD72FB6477B273844C5AFBB6
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0081C60D7C1EFABEF085FCF80FEADD074C2E541A448EFEF72EA9C2E6CA06AE5554
Coordinator signature
EBF297B291E41899082BCA1E05FB57D853659C6EDF9A4749F5455AA5E5F8562E0ECBB38571DA753C1B9CAF018BCC319C19B4214AD724C35FF9373CC43824570B
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
ADA28FFFE42BAF2C2837AC8D6D4B40CB6C765A2F9DA057524D278A29457A8DF8487BC33A07529CB2C4113A4D108DE51403862EF39B5D231D3F7990051E4B6405
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
88DE8EF41C586B17D3968B251B08252F674227A7F667EC2C7F5CE3BD5D8B6232A14903A5C5282201A468FB6890C211497A9960B7BF46F7FE937FDD6C7412910A