@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: 0x000027DBFA6C5BE7B6BA69D237DB95C4F481DBA5B608A82B7D98BCB70B2A3A712F86, amount: 123
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: 0x000027DBFA6C5BE7B6BA69D237DB95C4F481DBA5B608A82B7D98BCB70B2A3A712F86, amount: 123
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: 122.631
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.369
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 122.631,
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
71B228885F4526F2EAB49B35E2048EE7CC529A51EA496CEE029BA9562C61197D061B9AB6C84D26BB3B346F9B8AB1D9B7D9EE3DCA26852691B691AD02
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000B8A3...A1FEAt 2023-12-01 16:10:05 UTCAmount 0.43315965 UCO
Previous public key
00014D6B6763C7F4DC73796377569D68866B262C34FD2CF5E1D853D37EDE3AD40BE2
Previous signature
A39C4790CEEA059642BBE9809E0DB5D6BF68632CA6662187996E0A166D0FAAF3B7941EA50BAD6F05D341B047C15FBAFABFAFE9C0A92625057D4F7D26848AC608
Origin signature
3045022100D50F5ED2D3BFFAA944B0D80539B477A2827A10C902E031922BA6280E82A4739102200B2FBA9F6D24AFC6ECEAA38AB7833B3AEAA64177EFD73BE1F0B728D20A2B70D6
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00C098A8847F01188862AF607EA40A8045FC9AA902F318F7BA1098724C981086D8
Coordinator signature
B4A6B8660A24B5D0DE40CFECDA34A7D8C22808A70230E822CF1ABDDF7C64161D93D62947C09E58C839C76EF33E2A62B0E1FB1575E6AFD013869BB1B5E5ED120F
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
B4F0D5DB97AE51D16B0B007BA54CAD11B866878AB40D247F6039C7B4B813BDEDD1EA2B7ECFDB0912657A318CA03171707C9FF31FD4377E5B445445472E20C903
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
C6E7DAF760E9A7B1170308C593E5247A34CDBF8C9DE85C6B247EE3A0E546D033696B2529CF065826D3C8E40E6BE507B61043DE23F4494DA888FAD75682BE7601