@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: 0x00000415C63E8DB898974380DF06B9E013FCE0C2D3D8CD97D63901351BA96079B47C, amount: 6
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: 0x00000415C63E8DB898974380DF06B9E013FCE0C2D3D8CD97D63901351BA96079B47C, amount: 6
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: 5.982
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.018
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 5.982,
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
7F94E0F04F4EF6798AC69795FF49BCB11E756FCB0A09BB56A641A2C7B2280A781FB7134E2FAC41C4AC024270648925AE6A7EEFBB9C663058A71B72D1
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000E23B...5CEFAt 2023-12-14 05:27:13 UTCAmount 0.43757772 UCO
Previous public key
0001DF4BE68A2FE910BFE889B15799E8044B4053DD70325E914176FE05C9927D0032
Previous signature
47F40C37A520DC04E1EF6A3FD31CEF917D25984289822B4C9DE78624A5B17DB80B088DF7EE571C99A183EB07A705D9D715F20C94F295D515D9572DB4B3150803
Origin signature
3045022100867B6F1B4115BDC5C9E17545AA31A6A38CFDD227C7CD51297C690DA35C5B59490220335EF32C83408521AD7288E42E5E59FE643E40CDD905B8B484BFE2E04A57BA83
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00C49F924CC26BAB06FE76A6F3335F4D0AA23FD400BCB269A5BD7E7F3DE03813B8
Coordinator signature
C5E0987F2280C115049473C7F1A534EA883E616290057F008BD45C93477E16426C575A881FEB27FE772A4AEBD8B53E9883CEAFC6E9FE0D8BA5282E67CE26450F
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
9DAE56B91F1CB5C9B290BA30FAD390B0475ACB689438D9FC3A6F1B55F46E17ED3FA4C49FF1B4A38FF81AD15C7395E459DB94A2A90F5E15E7B4445A0829DBB009
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
53EFD877049C45A634FA4EFBA6B0C07529145778B4458838B322B49E440ECDD638B3AF1E4C77DE58DDB10AAC515478E7A35414D9848EAC38183961FDBEBA730E