@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: 0x0000F5DE05915F5AB06FFB480B86CFD0A5FCB0306C9037E8E0137014B97AF7C8A748, amount: 0.005
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: 0x0000F5DE05915F5AB06FFB480B86CFD0A5FCB0306C9037E8E0137014B97AF7C8A748, amount: 0.005
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: 0.004985
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.5e-5
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 0.004985,
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
9AFA9A14B3E0959CC1A3FC2F2924F71D79652364CAA8A62F866B624153C77ECF9ED964E0E5F305747B5E73FA242DA7A7B8939A8571B655FEE1B1C1C2
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000888B...8B4FAt 2023-11-30 01:11:17 UTCAmount 0.42168882 UCO
Previous public key
0001D1ACD2933CCEB7E9F422D414F99104BF0C70B204841F36C8CB771680BA4040A7
Previous signature
A73FF4A7702588E69A4AE5D9D97E8CF1A53EAB682EC6CB775E1EA20A8F094215A2166CF130217E204152F0AEE73001E9435867AF7B259557698E3C01A8368400
Origin signature
304402204794E4F0C0824A9AD510FAB67FA0FCB8BB8A552A9E1163E9F3D4ECEF8F3A848C022039AC456237016ABC6AD9F307226DA42A804C7EB9E0CE64E62415C741202C532F
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
006BF79D14229CCAD9899013E7DE1B3F510A2AC812F96E7EC6EE11726963582B8F
Coordinator signature
A30A5FCF33506BC8B3F553B16BFE7193011C11ECBA3FDBE9939BEB75DE083CB3BD2C2991E5DB63122F61A8E4B6C068D7737DB02E5E92BC892269792206D7900D
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
68118748412F19280B7FC172B43AD6FBFCAB99D931CEE401A58327476276B100B2C1C30BEE2B44B3D486ECA5877F73C8F619E44219E06106D1B0C79D79414606
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
A4963FC140725A28E1815535BF5530972F544080614121BFBC9DDFB072019234334E37B3B50812B8C7659B0D3DFE6A3A828A0F4D8CDCF9724607342817957A00