@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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_token_transfer to: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 0.1, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
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_token_transfer to: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 0.1, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
),
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_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0997, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0003, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 0.0997,
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
7264A850D60BA745EE73725AE77675B966D9452C578BCF846A9B5C9B30F3F7EBD3D2ED0D924A0B74FB1542FE637CCE11DF4B188CE50D145F5E3F7612
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A8C4...B2F2At 2023-11-30 01:47:08 UTCAmount 0.42589913 UCO
Previous public key
00017C0C9FD0A84AFD3D55C0CE7DE4B1D367E7FCE844D471AD864CEC426891C1C10E
Previous signature
AD9BD10FF7A78A1E2E428474C01A93C578E60F810A2EB78C30B4A41419DC3E7F8394BE3F72D68B36B56115464200CA06C8F4468E0E2509FFEA986BC0D4C5E80C
Origin signature
3045022100C4A56C74810E85E12D1B5E5649904CBFEA32AF77599D9F2FA320A4E38987D84A02207EBEC93F13B79705B2B0E367CDA6884546C92ABE6274886844720BBA106749BA
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
007D233CF5225F5A8682E40B3B49323B60347E8E8800E92607490D8C2E54627D4B
Coordinator signature
7D36D39DBD26DBBCD6E46B3DB889E856F153F57C9D43EE10539DB01D9C847CDDF0506CBCC9D602E0939D4324F5AF3938BEEB9A0CBE516FCECBC3529C9207EB0C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
6468A11A6BDF6BF92C9B8FE6C4DDD493586C62148A95139AA624EBF223B36D53DCB57900D69E516B3AD3297B290AA92C6F4516E414C08C3F47E933C763C8A001
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
11B7864DFF7B952BC576C4DCA95718F4D5C5C9A6AF572D3764D0D1DED7E6C97AE1F1D6E08A7CF5144479235CA2D596675AB363C4FF5AC9C183D0918B57090B0B