@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: 0x0000A13340CA5E06989B6600C5B84FE8CDFEF4CBBA34041203EB1FD0DB386A469337, amount: 5
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: 0x0000A13340CA5E06989B6600C5B84FE8CDFEF4CBBA34041203EB1FD0DB386A469337, amount: 5
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: 4.985
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 4.985,
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
884A544FE3B742E9631C252EA0852D3BF37081536ED751F21D9B8538F852E120EB98265A7906DEB5204CEC5DD45A0BFC9AD45265C4D9B840C0BC8A0E
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00004859...5E08At 2023-12-09 08:17:18 UTCAmount 0.42194036 UCO
Previous public key
00018F0921809343A79C2A96A1F0EB9F939F304E3FF3CB8BF356EFC0E4F9762639A0
Previous signature
15EFAAB172FD2FA1D8912EA3CE1FA2E63E5EB222682593CA7B27EE78E66B9EEDB290BC998666FD653F7480121D3C9E932543120664C9CE8FFEAA453410522A0E
Origin signature
3045022100A72727FE266A2F69E0AFA6FFBF2EA2B7F8A706CF43976BB47EF439B1BAC13488022036F415513EB13F27F286DFEAAD767F712410B5A6BC69B7F7CF1DC03B697A7EAE
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0033295B0711FD35FBF2AD8E44518A4CCFE0B829C8BBB610D6B20FE8ABB4E4503C
Coordinator signature
8164423822E985E33D65AABE3CA3B68A975D8CE0F859E2545B94B8669AF6C3490C610FCBC28480158FD2D9A03455D9F4EDA2D248B43068602DA9E5539C5D1E08
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
0F4F367442896D955C7D32EF05C39135FFFC9823899B9210154808ACC709FA38DB9A933FF98A97140EFB5B0FF0DD064EEF90600A414DEBD6E67F6DFF64683A0B
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
742477F7BEE97B6B2FE401BA0FD2F43836A79F01BED90B597684B3F87F9A0F609260878CE89C2037865A7FA621084372EEF7ED17D4B95C932E01ADA0E1D3F10E