@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: 0x0000A60676622E63BA85AD07A5216C78BF3A95BD8BCEB5617642C3C0133A4611A745, amount: 100
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: 0x0000A60676622E63BA85AD07A5216C78BF3A95BD8BCEB5617642C3C0133A4611A745, amount: 100
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: 99.7
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.3
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 99.7,
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
9DD1453FC783D56E29A1F135543BB632DA6151DC3CF8C3691DA9921C8C443C47552A30A6BF4D8F45E6CD94594AC35DBDCC65D9C90995E2A1CE33441E
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C618...C27EAt 2023-12-14 22:54:11 UTCAmount 0.44394357 UCO
Previous public key
00016CC4F2FA0DC2F596AD8112625CFA5FFE4DC6AB190F084D0B978BECA597368A09
Previous signature
DFB8EE3672E4CECBAA0229E0617C50BE6F15B142F195843325BC49F0EE37AA8F5032F12410251F2F5B89E73C2EF73722D1901E5E294D54D8EBE3A26D706C7703
Origin signature
3045022100F24099189CE15C3CC2E134DDC3C087338539316A65289329C826BD34D85AAE28022002CF347CC479B4C121D0433B6F0E1DEC3FC398A95BE340BE8C3056E85C4E08D7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00DFA9FBD86AE3ECD51CE25BB1E5B3133B8C086138ABAD9AD4D49DC003C96BCCC2
Coordinator signature
5C6460CE4B4D9C64741E13214047F0F105028A268DCAC7A683DB1C1EC046032930A2C71A4FDE15EFBEB0B3DBAB41E0FF992DAA120F46164D620BAF7ED4D25305
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
A7E919BDCAF83CD5D7EA7D952A813BE23809317DA8F67666CD81D7033A801F6F43AE4247F8E13A87F502CD381764BB135CEE903BADE2DBC31AAF72110DF71C04
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
1B7DAB3A73B4D516B677FAE3E12D88FED8A86136CF9F3485661C8C2FF86B0365473F9BEA2BD8C025A28014C82E2829D5FFE5A2442B6956F7E3D231EEA9B95101