@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: 0x00003440BC8E123C7B9102936AE257978F775AA1DEC6D192ABCFE5F123FDA92018D1, amount: 75
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: 0x00003440BC8E123C7B9102936AE257978F775AA1DEC6D192ABCFE5F123FDA92018D1, amount: 75
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: 74.775
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.225
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 74.775,
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
6FEEDE41D939E87C8E8CBEBCB254AD28D8BF104D5335E928355110D8F8564446C3D35810C415A1D25CA44B4B9AB1AE0AE916F7E2D42FB4BC587B69E2
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000097E4...ACB5At 2023-12-09 23:31:09 UTCAmount 0.40917252 UCO
Previous public key
000108F0FF7DC29A4B11D2136B3F961C4570E3EB1F19A59D24B7B118EEFFC56CBB15
Previous signature
08B9B8C7E4AD96B16CFCD54EE29F20FD896AB9F81A994F8756FCFAB24D580E76CDB7EB8F056BFE8D4CD2040A8A83776B30FE1D25E5E789834AF6D39002B2AB00
Origin signature
3045022100903A1FEF118085D22DB8D017B7D7DDF57F66F6414665CF25324DAB87884C7B840220609B630281D5047AC1C08C2BF3D40303B1CC5914076B0052447955B9A2F897C7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
008DD2AF206A8CBECEB1B015063575D1B9BF74E034FD8C35BC5249397F7D11C94A
Coordinator signature
8741903F75A29320B87A4D32486444E2E890F77214FFC022DD096890A9634F024FFCE7657224985492E0C5234D5F1C03388EBC3CD2DFD18319C633ABD753A70D
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
891E84861CC149B6AEEC6B368E8235A004EE0BDCCF2FA4008102FFB4C92409158457272A86F8D3C0AE7E896660B2573041A5D348DB8306B32610B61C486F650C
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
8CC2A6B7CBED34279CECD129D6F8B488FDE2E2E83D92898FE07B8FEC048495A89B2DBA6F6FA3B546777EADBBC8E2CBA22F39EADEC536CEF045AFFDD9C4C4CC00