@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: 0x0000D05315238AD9754F13F7AAB883721AFA17F02E9D6EAFFA759E502AB50596B4C4, 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: 0x0000D05315238AD9754F13F7AAB883721AFA17F02E9D6EAFFA759E502AB50596B4C4, 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
755B6F7B8C5B768CE35DB0524E3CB8D6F18B6B6A2B8B0775DCD6ECA1A9CBB29D3D2B7D46DF94F052946690FA425B6EEF46FC27EDB8A9C2AB81B1CB62
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000AF78...B22FAt 2023-12-01 09:18:09 UTCAmount 0.40622451 UCO
Previous public key
0001A0769F8A83D58E5E1C0E81AD2C817A1513A88044B063091C80D50398D2D2607F
Previous signature
06B8F829D6C23318C97D23FE0FF912FB820955492CB09A2A8D2C4069DED6868C222A8F9BB3249F0C1A082CE766E6291CB1F4B5F766C63E1A05EBE6791C769D01
Origin signature
30450221009668CC5C3DC41A1690DD375676FFB527B9254C81B350212DE116CF37E89CA6F30220733587612908A5902B4FC6442B6C4129107A9A64373DCCA2643E46D9DE2D228B
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00CBD7CE79799601FB2896C404A00555577CF12C821BEB4A9531780D8A5E326A74
Coordinator signature
2617AD4DA78D7EEACF40BE293A04993E039C724490819159B8207A3013EEB381CFE307D818D32418A1120FC0318246010930438CF853A7FC4992BB8159E1AA0B
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
94C61A89B2AD4CA079D3CDE9E5744C5E99E5B5EDE6A36D25421DC1DD25BB6A6ADD87BFAFEB6D7FC7727A026BE2C8094134C4C802178F5A6AB3EF9C1EC4589602
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
F66813A063FF378656CC682FB5577541E377E007FF3824C2A67BA074DD69F639FF0933A0889C203D10E4A7530A0DAF4B51F6F3859110479F829B74E43C9A5B0F