@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: 0x000041A175F53C2CC456DA2C8198377068A2E3F4F59B9A04B5CAD677EC43F4BFD081, amount: 20
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: 0x000041A175F53C2CC456DA2C8198377068A2E3F4F59B9A04B5CAD677EC43F4BFD081, amount: 20
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: 19.94
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.06
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 19.94,
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
EBB52E22A787F8043FAD3FCF13A016C50A60C047A0A9BB5C37877BEF25D269FC429305AB3CB8C1BF02FABFAA2C6D5AB9DA4CC0156356C782EA6221B1
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00001746...5FC4At 2024-01-04 15:52:08 UTCAmount 0.40427763 UCO
Previous public key
0001053D63948D022CCC8E5975A0D2A487F8912D0FFE6F51226524B71E96D558A9DD
Previous signature
267E1218830511D40ABA5423B0F0AADC203C32CF281FC2C4F5BAFACF9C8F661E798C83682BB2D283EDBF93F8BAA35DD18BD7D271E865EEDAB4A8085069782C0E
Origin signature
3045022100E9E4F5FB3870CD351C3C89F37B8957AE4A64F0D252D29D02D9FC379053F8625F02202ADEACB5677E4D511D62073BB4ED20C7B186582198EDD510E9233770C7BE8D7B
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009321820251AF1ECBA5AAC3BDA22A3C330B4FA3AF3EDF54AA5F045EA8391071D8
Coordinator signature
1058C427EBAF277B5A2E3A7907AA036CF11DFDEA1EA379BE871ADE349E425137B6DC7F8C4E38E130D78AA6885AF438AC56F5DABA8F5A083897121520188A780F
Validator #1 public key
000103E30584AD8DE66F9E29419D5D0ABEE5A76722C9FD0D012BDDE3A6E2B149C48D
Validator #1 signature
F6C4945B55A91FCEDA09E05335E752EF9F3113D92B8D4CEE4B77A57D3D4009DC42BDE5179783D6B44C62A7FA2BEB2932668BAFCC915956F7EB29F474549B070E
Validator #2 public key
0001B01EEF96BA7E95FC844D456CE8868F18864519FC9532E1751C2035FD044DD5D0
Validator #2 signature
DABDAB170CD301023890C890453EAB283BC0634F2B71E73F5993DD5DE9972746F5AE2996DC5B399601BDC51962023049E688635E4A1026D356C008712E8E4B04