@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: 0x000080D5057516F335B1FA66F82ACCC4D05BBD983ED957B5D7D67505A4CFE10277FC, amount: 10
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: 0x000080D5057516F335B1FA66F82ACCC4D05BBD983ED957B5D7D67505A4CFE10277FC, amount: 10
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: 9.97
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 9.97,
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
5DD93AD6E686F5F6EE6C2A3128F99743301491A7D2A0FD6ADE4F6C8EB12216C732FD015C445B233F3EB04EC74B07E4544E49D0B5876F7A49CAC74867
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00005EC9...FC08At 2023-11-16 15:32:19 UTCAmount 0.34408374 UCO
Previous public key
00015B12EE71C02EB38EE942BF634925AD69A9EDE702206677E7E5B002DA671FE170
Previous signature
77215B6670DF22D820980293A975AA023DB5D1B7D3609A3231B605200B473D29A6A63DD369C0056769AF096725502F750B87C5BD1430350F7F751205CE24E90C
Origin signature
30450221009CC18D3BED7AB9BDC09640F3AD4346D6DB88DE25C260CD67F42B8F11048969720220411B4FE27A9524A00FE6422C8D6A88A4274AF1D9BC878754FA234F3AA3358923
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0075DA36E4295364A3B8CED86CFDD08EDAC92576D512CEE821E1487EE22D159DBF
Coordinator signature
8FB59AEBCEAF87186955C41EDDE1DC07EE41A97D578C2E47BA0362428EEA04DE1AF9B7BAD0C7B1A5F6E536FD667D5AC7E9976F155853472B8BB96068FC90AB0D
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
1B4FC5036036E54B9E65ED66CE8B723019CDD9D30015E0C7A2FB0AC39D26546FB5293325CD5FEDFF3D57BAFD0E2444E256EF2B27DE3427A1AF9CCA4FE8135708
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
FF3CD87DCB801A2975E4E7B289884681C6A81117131C3E5CB8809EA467E1A7B2E0245B29D1137C5A7C9251511851DBAC61B306AC45B806894559889F7A062600