@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: 0x0000BC3E968466B3ECB6B2E6750A561DB3A55B61DF0B6629AC85AE9040DD5927B389, amount: 150
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: 0x0000BC3E968466B3ECB6B2E6750A561DB3A55B61DF0B6629AC85AE9040DD5927B389, amount: 150
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: 149.55
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.45
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 149.55,
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
FA22A9386CA2EB02A1B02CB69D5567EB79BA39CA88F125F2C47BA486029A017A83D7DC6BB96957FCCD5F7AA274F9B3773694D1AA46CCA4A8E4BB09E4
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F238...F66DAt 2023-12-08 13:33:54 UTCAmount 0.39532274 UCO
Previous public key
0001F9F8776C7A8F17D6940115E901C5C4BA80C8846D285F3E55E89874AE9BE604CB
Previous signature
07FD46A98806829420482BA2A9B5F802AE9F9DFF3603F8639DD336BB9F43C9ED741DD9B91644A0F0DB5A79D2FC0851CE8006E8F201E385E62206940951A44F08
Origin signature
3045022100DE9B8BF21F900E9E6F5B803176C4478638C24A3F4B4AB850C32C51F2C199C5E302202378A078F3CF9A76F965832347946DDFD8793AA483E090E6018F3AAD13490566
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
001A496E01339A689378FD19C27A0F46502F0D50ED4D5A4EBC4E30EC19F15C7056
Coordinator signature
FB00C605C6BF5FE5A30ADAB77FD4120D8E1852A0D2DCD44F084F7B5FFF505ADD9D3D8E707743F49B8834796323157A63D8866AC275D789622967B6A1BC485502
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
9E07566063004321567D55C233E4119F9F40BAC5BD9E31E73C6F9248D4C6F2E857609107F2440FDC5E9F1D6D92385E1D21E0C456AD23DA1AB93E8D7307DEAD05
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
5F9ED459CE619BD56B976D704A81143476A13FE717FD177732ABF17F6E0C52FC7C6C10E3E3F50705994EF3DB20F252F328520669B64BA503051F5580BDD02C06