@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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.001
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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.001
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: 9.97e-4
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-6
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 9.97e-4,
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
89152A35A36AE19C2B043959C7CD2C1BDB6C74DF83A2390FC56B19480DC78646FAFD64015AEC3EFD1BAB9873A7579C282C2A546557B5135D5B3763B7
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000FE67...0C10At 2023-10-20 09:42:47 UTCAmount 0.5016515 UCO
Previous public key
000120E6151D097D54BC995E95C1756DD44C556BD3947EE66170C1F992AA4395E26C
Previous signature
D87735B595B988BA9A895D02043C991E46869817289F14D14B2F563905471E7060FB58D86A22FEE532345499D64A676F22B3D38E3F390E9BF2B6BB64F611200D
Origin signature
3044022025427E192745D11B752D5D827CB68E3CC3ED130FD458E09BB7A3BBB1C151371802200D44FE37FAF00D588FD7864414E62C68CB4EBD79A745004010124D59DFEDA77A
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
005468523D24D171B4CDB72D473B9539B8067139A064E49E57FFCC4E7C2668E2C2
Coordinator signature
BBF6191A4C11BA121390E2A984F0963A519C3012AA5F4F7456AD63EF861A842DF264D8E4671F0B3AB16EED8F9BBC1D16B00E1A1D457EBC1CA78C758B9E9E580D
Validator #1 public key
0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34
Validator #1 signature
A02ADAC3D84FEC28BC11F0DFE17B2C311C5716A615293337E2F23F7CC986811CE235CFE7EBB71F982CB09FAA9E5BC42CF959238F66334ECC14CE1062F46E4605
Validator #2 public key
00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC
Validator #2 signature
B6C5C349E0190E0FA26125211DA355CFF7AB717B932523BB5F12463EEA25073428B4CFBCEB27F2CEF22BF078AC9325AEF659EACD2C2153F65B633360164BAF0C