@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: 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: 0x000083B000A5BACC553C131B64C034EEC5A6444A69B397ACC929549161B820CB99B4, 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
605EDAB117CD0676590B12D5948A4495E154EEE63B2E7009B0767D5DBD1001C924ECF03DB3FA073161F8C35EE71970787022F9A262B7F06042225996
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000685D...4271At 2023-12-01 13:26:53 UTCAmount 0.42497326 UCO
Previous public key
00015A1BF0FF7F0D3E8D2DECC0C48D937FC3A35D0BB979A49E3782FB92A8626EE8FE
Previous signature
1165E440ED8B6F0FBB0445F8345A5A24F7A83CE89735241AB836461B5B23B1B966534E88DD67038E5D6598C5B656EE7EAF08271419537C16353F20C67A42B608
Origin signature
304402206EA7BC9659A551219F9FFD8F0B9ADB21A8981A4BA6CBEC19762D743BDA25CF0D02202DA974CE4F0C14DC69629E2D22DBCCC83BD4F3F4FB548E379B8E50F50CF99358
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
007AF651B83B1C68E4D6C816EBB8B0C93F00EABBB30B4DBCA61BF4EB40BB529CFC
Coordinator signature
BD6B98300853ABE1A47631F7B5AE63285726F2E06594458CF9743380FDD5C1A335CC0D467D5A9E57205585041751AFC1917E116B4AB9ABB28CEDDF195D798208
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
FAC7497916FF88B702FE143BA12251D79F36C00F359A21FB4E1805FC9B6DEA3D3A00779982643B167130C054474716C1AAAB4164555F5012B6A4AA6D1E763301
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
9DA60092FC0534D9CADC083F3DB34F3CEBF36C0EB9895BF27322344A239646FFF8C1FC4B0782F124350F2A4EA3685C02456B5F0703E3B153C0B8FF90E82FE90E