@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: 0x0000D9E7B4300CC29670CA80010FE23292BEE4AE28057328732A0FF4CF11C319D81A, amount: 100
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: 0x0000D9E7B4300CC29670CA80010FE23292BEE4AE28057328732A0FF4CF11C319D81A, amount: 100
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: 99.7
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.3
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 99.7,
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
74F18AEA8041EC40610AD836B1E8383CA14265A2EF0C8C073B59C44F3C528DE696D1D9A7F6AF610912F075FBC1B91BA843532975FF17A976DD1F8F45
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00007F21...7B5DAt 2023-11-14 19:45:58 UTCAmount 0.35429422 UCO
Previous public key
00016C01BCA13D7E6DDC66C816DA8A922D7A3883256F52E20A3E1A7C6E95DBC3623B
Previous signature
4C7FFBCD371868ABF3B6CD31F9A03B9B36988EEF8C3AC410FD200464D27FCDFB82593B27BAD9CAB4CA2BAB784436229A6974951E998B9EC12FCC244EF8517E02
Origin signature
304402202F7B8D3BD0D9B589F0F645238C5F1187680F71A3260A5B6C62D1F2EAB3E09C6A02201C70897E0FF64FD8E19FB5D288C57DB81457990AFEDA7761FEAD5FBB48589285
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00F9C1CC1C820561E81119FFB52C4554C9D3C43957341428084820855C00D5D70C
Coordinator signature
A334069F17F7F20720540E9773D1661DC397DBE790446C3B8BAE7EC4C04E1C9AD0EE61EB7C27646B1CDD095AD62AAC9B3057B952D49F339DF08939E6116CB000
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
12D15F1C39F39CD715975FEBBD7F8B2141A0F68CDFAB64BA68D381B991E92937A9FC2C2238AAF4504F752037A09F5368EB72D0A076CC3F23DCD855A7C1C95F03
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
3E2D043B3BC5CAD6680A1A4650676EEEFE1CD6AB812222560B9A63BBA5C49E408FF0AA26C0DC1102EBF12D71D773C622057914403F3754DAC240DFA58CFA3504