@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: 0x00000074711AC67E712F33FA34FCB3388738F232362F4852D06A08AC62818DF8426A, amount: 111
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: 0x00000074711AC67E712F33FA34FCB3388738F232362F4852D06A08AC62818DF8426A, amount: 111
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: 110.667
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.333
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 110.667,
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
4DDB4C08C8825E4DA09EBC8A2DB8824829F3FA501C58604D541473076196B9BA21C9829AB83889243B153237BF520A68797D218087E956721838A376
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000080B...6915At 2023-12-01 17:09:20 UTCAmount 0.42641724 UCO
Previous public key
0001FBA41C6428C577CF153CEE62D5778947707194DA9BBCCB856ADF245C26B0528E
Previous signature
6A2D0C9FC31EB734A421041AD2CDD4F21F43132DAEF9D62936297590A0F26174BE005B40CFD754A071477B9B3CC98BB47494C6553277978B9B1C87E185021207
Origin signature
3044022009754E4405248B2D8483B21D3F52507FB7F5ED7C3BA57F038EAF6613F001A18E02207FE30FFE9FE46EAF0EF37A86A80AFE217DA36D5D0DBB31B65F8EBE3C732804CA
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00757CD2B3748F6D3850CB7C4745F08F5A7DD6CFEBC1AEB28F77FAFA4CCCC9D33A
Coordinator signature
887924AD3B35C8862D0DBA1731986AC328A13341769864719EFA45F8568FF8CEFFF991B5A3EF5B4DA68F31CA53648A64A89EFCFC2E28E5CAAF97096F1FBD1C04
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
D850B42D18556E6A45346D402264F53595386AD9631ECC1D0FAE6308309087B256331E95476C5BFABE1B709303A5F0D2DF2ED2F9C8E199F38902FB4BEE27AE0B
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
FB1829793FE27F7A4F0F8DF8738BD365383EE01D2B2CECD68B01B535BFD9FDE51E78FB38CD76512C95DA5D813CECB383412508D6E3C4EB56772A462E51890B02