@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: 0x000006EBF65A8D742B1176B2624E031A76BA2BC7D3284705426E8306C5A92A1FA9C4, amount: 50
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: 0x000006EBF65A8D742B1176B2624E031A76BA2BC7D3284705426E8306C5A92A1FA9C4, amount: 50
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: 49.85
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 49.85,
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
70B50E40BD407C960EEE99E532AB611B070083E2C2F289D1BC2A9783879EF492787BBDD44705D6DC19AF98A27412264A5D7A9A94F797B555E1709277
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00009D5A...03CDAt 2023-12-01 08:27:17 UTCAmount 0.4056667 UCO
Previous public key
000124EACEE646066C47AC1402C6DDD15FA655B5DA6A51FC45DFB1B540242CDDC2A8
Previous signature
EB9A0E63A7D2EE4C7D3ACB2A74C2EBA4A20630110B9789018ADEC7EDBBA46A34EC968644D897C7CF40F02F500F3AD3042C387D6AD1632B1A4A182F05A3D0FC0A
Origin signature
30440220081671349B890B1CF5017324EE3833C045FEC18A4E980101E9FA1D9883A98097022034D0B68460E5C45F569777ADFD37409F2669E6BA435D4A4FBC76DEC0D943D1CD
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
003689FF952373F42BCD9E3B00F28038E3C517B487412D42907F7D6968098550B0
Coordinator signature
325FF3037E4394AB0EA8160EE884D9A200619AF568628849D0AC7956BEDA3D0B79B01BF084F990BFE7371CBB605CC43CC9FD9B45E79709BC46CDD95A82B5F607
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
23DDF5BE925B68B62FF959444BA0890507A5D8F93CD59530227DB3A1292E5FEEEA7B0434BE6C22E17C6CE74DC4D8792C8ACDDB7645083F122CAA7BA06A9DEE09
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
F7249B5A122443859ADB3CB4DA0FE3A8A51DC4990C2FDD17476E685828B2E2B582AE79BC83131EF3AF58FD09525408867FCF1195E2420E45B2DFD94F56D43A03