@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: 0x000092BA2D068F2D89376216B38D2D8D5A832B0C80C0F3A6B79049C8F4E84CF155A9, 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: 0x000092BA2D068F2D89376216B38D2D8D5A832B0C80C0F3A6B79049C8F4E84CF155A9, 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
81BCC1828634E17322950A11B9D4CDDBEA6710EDB88EDC9DF082C0C4C5FFB28A2211DCB8CAD9B4E60B1BDCF247E2AE917D8E0B3BB1FBFCDBC86D26DC
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000B6AD...E524At 2023-12-05 14:40:27 UTCAmount 0.42824124 UCO
Previous public key
00010E4FBE7A2ACE558A1E322133E342AF85068C1FEC6D605105C3FBE61B8D82B23D
Previous signature
AFBA1E094FA9EDEABFBD51F47F222149825240A4EB28BC5E147820CED2B89BAC21547FC48F453AEC1C8B586A906D91510D0FE146A18607480FC6017DCEAE630B
Origin signature
30450221009237DE69EB48D396166C3D14684EEED7C35E666E91241B9BD22F19A5A432F3E602202406E048374FC234894FD30E83F91B6648315A2606A238EC6CFB1DAEE1BBD482
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00FBE61C6ADD41D9D290CD9A99E769E4AC48CB0FAB3F461986DBEC85040C607D25
Coordinator signature
9642E2E4FB99CE84CE2EA4ABA36D938440389138698D7EFDC884190A29F2AD32DAFA0479331B35DCAF19F070DB22A7AD32DFB777C6AB2065AE3EB23420618301
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
7CCCF86710B0F55F62A2216F881A622BEE16F402C9DA9E6A2D8A09F85254906DEB16F7A12829F117E800FF59B9B6E8F3407BB227748149AB967FB69CE81F1106
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
C9F131C23CB3442B7D500488A289BB8416B8DCBE5D87DFC24F3B196157D076B88ACE8C5EF5F310FB23F5F6CBD93AB1B20AC3CCBD6134957F0A1EB28C4343A505