@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: 0x000004BE34D15FF077A60B1FCE897083D215A3C392BF49CFF15030A774FA8FDEEBD4, amount: 200
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: 0x000004BE34D15FF077A60B1FCE897083D215A3C392BF49CFF15030A774FA8FDEEBD4, amount: 200
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: 199.4
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.6
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 199.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
835863B6B5D8B586CB0D510159A170E3CE31B30395719A0990A2A7BDC92A768FC7D8704FE4C5F4E21A51CC04320C873ED6AF3CC6BD2AF23F33B482ED
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C6C8...12D7At 2023-12-05 17:20:40 UTCAmount 0.42498682 UCO
Previous public key
00010092965B736725CEACAEE73088AB9391540EDB21FF85C9F633F97D34EDE4919C
Previous signature
A587A8FD8A12A38EE90A16D4CF5B10B549F79F52EA97228A5383290082F6BDE6A9B454E88F71CD8126527546EBA45EF93BD3091D592773CF22551E4BE2D1E703
Origin signature
30450221009F7751578507440D400EE247CD84170DCDABDF8BCF5A6A23465F1AE7FB75820D0220553AC7E5B61BBF3291DFE33E2B5C648BEC08F11EBB6DCDDF93AF9076C69BC87E
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0016E7DDC37B6D79D370DEDE9B326C9417C7059355BB2ACFEC2D01BC2A5B5E0B88
Coordinator signature
A8DF2F72FABBB67C8CD22F01EF5C2EE6761F8C90FD509CF50AE641A0C0EC20FCD27AE7A51940F0BA5710666E87D3DE76871A6B068F984397A5D5786782FBC309
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
1C57429EF2A2362671A4AF2A779775A8F4F04C0F5CA80A1014C164221B46863F41EA27F9F1412C55664D20B1A93E09B4EF72B389C530E9FC728E20973AD2AC0B
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
06174C2764AFA8420C0D46F499DB3BDE5F5FF064C39BA372C320A2BCADE99231551BDF4A4C2B3B5E6F196DBEF20A99B921ACBDE2EB90AA7B6CE9BEAB6AEB5F0C