@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: 0x0000A60676622E63BA85AD07A5216C78BF3A95BD8BCEB5617642C3C0133A4611A745, amount: 50
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: 0x0000A60676622E63BA85AD07A5216C78BF3A95BD8BCEB5617642C3C0133A4611A745, amount: 50
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: 49.85
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 49.85,
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
7E99F18AD3CAF1B408A34122CCA263C924BD97ED92352344D223ABECD9D3C979FA91E5B269C300E9DE321F546B5443CD27369DB1A6234146CBE6AE2B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000381B...06F9At 2023-12-10 12:15:13 UTCAmount 0.42151448 UCO
Previous public key
00016D1E1EB9202029AE07AE93F772B666421B220AF699D82435E6C3783A1E854F4F
Previous signature
ECAE8B9155F38BA914B26E2693AEB1F8C15BE1A2949C9F7ECA73D9A919F3ACDFF5F0133F91E67C367BC0F14289A4162488BCC90C38284B08CD3925CD23C37F00
Origin signature
30450221008732BE0B1AA43C11957D895C4FC0C7A0681DB03F214EC9DC504E744906BDEC5902201CF2883B6324404B1C8CFAF6FB70309C8B5C8AD29C81F21E414B4305B9E53C22
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0050417A77EAB27E059FCFC282DFFC56D3EC4FA1879AB4FAE032057C0CA81F11ED
Coordinator signature
FDE5893BBDCDE6473A769E1BE0B2C4C9307E7B3C63D8B55CCD80097B012EB3E58E8E78BF4BC6B3290B22161A7B5267CB401C8D71601BA64E61F581D2E923AB0A
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
18E725A5F486184FA1742BC9398F40F63980F17B7373366789E5671CFD5700DC31010726664A362AD763E3926441E11C284775DCCB21DC96FEC983A8369F860D
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
960D4A55D71E3725B57DCCB6F1D5211BA12AF2C0472C69779E658C3C398C5938A950F3FF7F6FD82136ECA9A77316EBF9DD552FEE14BBBF29895DD34781935306