@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: 0x000083B000A5BACC553C131B64C034EEC5A6444A69B397ACC929549161B820CB99B4, amount: 25
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: 0x000083B000A5BACC553C131B64C034EEC5A6444A69B397ACC929549161B820CB99B4, amount: 25
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: 24.925
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.075
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 24.925,
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
92C3DC1C7DAB0BA268429686581EB74B8D408DFF5C679794B9DF79C4294A5F84A8C912CEA6EBB0C3C3EF44FE0A8296D4AA0B5D20FE9DCF5DFFCCD648
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000681C...3D0CAt 2023-12-01 13:56:40 UTCAmount 0.42941188 UCO
Previous public key
0001856E7AE323C629E438209EA5A16B77EBA2BABEABC550F31BBA552FA12DD44005
Previous signature
71F2E6C3148E8A15CADC35FBFEA0F858B5518F5834414896D199BFE51F9B44BE2F5AA26FCE81D8CCF3E6EFBFFDEA901675542461DAA0873E532787BCB14AD306
Origin signature
3044022025A39CBDBB7B8865DAFF4DE514E6C698FA135FFF8E5A117C74F86DB46EB8F6E10220442EFBD5F72CBEC65CEA0F4B4A0D830FF630AF59842B8DE798B1640A760A6031
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0038A6171A7AD2DEAD707729E93940973A21320B9E21506C1B854160159C3A3965
Coordinator signature
337D989B9E92751FB26143CD493871BA60214CBE562F6FEE69127D45AAB823C2FA68457E9742A12BB84E523840FAEBF4CDFC914A921DA3F550D6FA1124A26B06
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
CCF075CE54A013AAC6462D6A86FDA8F253DAFA065DF511947A2A612CFF22EC98BB6D86B943EA216E2808E66E78F19FE81E5D645E8DE21127B157562F30C9C40D
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
D6DB124DF04BDAFA44A98724E9553B760C29E8E733193F23179381A2744B4167CFDEFD45F56CED041B1CD5EF9648CC6FEE3425812157C948FEF3553511C3CE0F