@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: 0x0000E3C9421EB5DBB5765DC3E2D9C451DAD5B43D545CBF6A3359726D321FBAE5CCEB, amount: 5
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: 0x0000E3C9421EB5DBB5765DC3E2D9C451DAD5B43D545CBF6A3359726D321FBAE5CCEB, amount: 5
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: 4.985
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 4.985,
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
9A1A070C7D7065C9E7630A81C0DEA2EAE0F6004F01035182B04CEC8DD46391756E2E54D2303B9F81A403C51BD47ECE7EE078C1F9FC9D2CAAA252FE0C
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00004AF8...DE9CAt 2023-12-07 16:24:25 UTCAmount 0.39297108 UCO
Previous public key
0001D845DC269E92BF8A000015B1C96EB285895D39B67EC590727F142E4569DFB030
Previous signature
B4F05BF903ED3F0712C6C8FD162D19446B64E0F677FA0B56D4CB20AD1BF59378E020EFA868BD7D50E38846075A3D51468EEC4886501F2A6D3030879AC6C4B60C
Origin signature
3045022100F05D871E3B2D87CE672765E5B737E0538C79CB37729D66D6EE677BC467B562B1022052E8B136BABC82F078E126A986C81E5F9353389BC5CD7C75BCB6AD6DC3526520
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
004FFBB7D3C180B57AE0CD6090F03B90AEA65F90F1EDEE07362479576EF41F6AC6
Coordinator signature
EC2D118A81DF09AD9A3F76FAA67F2688323F601B22DEDDA5A22DA4050E1F73497DF1C15791C10EBEC47098A7A0FB568DFBC2A5072B4536651AED6463B06BBF0F
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
21EBB944A3001DEA182A8CC608BABF4E98E97A34D30FA7535BE69608444F8E5E5FDA3FEED3E4D6219FF808975258712F08BDD96D4C715F6DD9AAE168EEEB4909
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
77FD7EDDD669B10749013882D121BDD55FF6E62F070734C2EE0317C8B485909DE15B0AD68552D98B37523E7C442F4FDDCD16AB2F4AA2E53798F493EE143F5C01