@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: 0x00009593AABE5D416FF4944E6C4C7FC0646A1DB894C5B5DFC774418F093034410B0B, amount: 10
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: 0x00009593AABE5D416FF4944E6C4C7FC0646A1DB894C5B5DFC774418F093034410B0B, amount: 10
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.97
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 9.97,
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
2775D7C5EFFF83F6501BE96ABEA84DCDF03EA6F4C63D03D1EB8E3880CD44C94650D4CB68C8C5C60381EF706822E9495E2EB5EEE773B1D68F44AE050F
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000012F3...D498At 2023-12-10 08:48:00 UTCAmount 0.41634585 UCO
Previous public key
0001824F4B3ACA63F243534D14B1F5E385F692FEDB42BDF187B4F570F895ADA19B9A
Previous signature
E66444A4C9F8AA438DD1BF3F3CD699EBB3AE1E956D16AE37F93735B357F9B8090813E57BB41FC37B1BC7BC06E2873227C0F03AFE68A247427927CB7415A4650A
Origin signature
304402205FD17A69E396A251C2C37979BB51FFD07C81C8A6B9DB035DE9408E6E76C5216A022073CBC240302FFFA26DBDEF8E4315EF0D1CF6FB4580EF2979E1ABCAA6659DDCF4
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0081145B8E2D681F1D5F5D8151FEC677E3BC30551A8B952A8902266CE3C2EBA2A7
Coordinator signature
47CFE4269E1D36E7EECA80C18296D317AAC6EACE324F810AB4F52F746408EFF52E1A86F4F044B97B4FAC2382FEC23B795A03F0C455DC4325B3F67C358948D009
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
76EBC26A87BF1747CA183A13699E0AF77750D3B2C9E8D1E201A0FDC0CD669ABE1B5A83040C5D1FCE4AC369B23E62C669F59BAD41669752E82BDF274C7ED4320D
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
C2384C07FD41AEDE9ECA0456F094F6B947BA3B5AEA5FB499DB71DBD58B66867A761E8962517D4ABC251E4FD42FA88EE2206DB6CECA378A41964A756DF29AD605