@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: 0x0000422C61F773320F920624B9E9E7553FDCBE8E2A291554503340669CA86788CDA4, amount: 50
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: 0x0000422C61F773320F920624B9E9E7553FDCBE8E2A291554503340669CA86788CDA4, amount: 50
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: 49.85
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 49.85,
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
2EA7D4B13B54F14E8683468CD46724A21C469D4954D2A2B5ADB5F73B994EF27F334A06C0F8B7771C4FDA4F3F6FA4750CFC49DEF59FAA47EFDA388139
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000FA29...93ACAt 2023-11-14 15:53:03 UTCAmount 0.35172511 UCO
Previous public key
0001DDFE0BA6B7B8190EA785C89F5A34AED1D8D24C9B9BAB885B3F2530FA08900D61
Previous signature
E3DD481018CC16BD73E79BE637C9990867A8927D362FF617D59124424B874198FC06ADCB135C2579ABD7A6CCC7188954DA4A8E4E9B163AD7FD3BA4A616B2CE0D
Origin signature
304402204A5CEE170EC2513C0C064731EBC7A0830C3009F43CD286DB40C19C0B5958D3170220241ABFF19E5487B6A3262012C1B1D7BE24E80F789C9C15261AB037A8F26AB808
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00C6ED33CDC87A5515F6D7CB1FE4FC7D36186935361FDA037C84D40D58EF03294A
Coordinator signature
111345B6158AFEF43CFF328CB66AE06CF3EF96AAB919A4755F4F57F1FF495B06A05CA794D60F82C3AC906083BF5FA858107E26604AD50E003B5C1F8A939CE80D
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
4A9BDD368FE0216C9073BBA143B2B9EAF869E3D76F568A0FC82F667BA4792C56115700773F4B6B1A7E14220C70469F14141171833DED8C49CD0C31DE8FFA5B0B
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
E30DD13BB4F7E2639B365CC4CF80F68B8D281B054E467843F94A2959A96DF2E126A6004341329D588554E61E74487C444312575F34953D5E706B5C3775005005