@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: 0x0000064F114419DD1BA0B495E4B596513A180BCC4F58643496F0919DCC3B6313BEA1, amount: 1.0e-8
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: 0x0000064F114419DD1BA0B495E4B596513A180BCC4F58643496F0919DCC3B6313BEA1, amount: 1.0e-8
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: 1.0e-8
# Transfer fee is less than the minimum decimals
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 1.0e-8,
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
FD1D74F781708C3CD995E51684554FB85A20CC0D33C2A0B342E52BE2D97A8CD414BA71AF77FF164A93F99F7079A2450DBF2B4675A87B168FF33A7143
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000FD1D...8CB7At 2023-12-02 20:01:10 UTCAmount 0.41575034 UCO
Previous public key
0001739045FF5CCAC67C6AF3DF7EC1330CD4251480F6B48CE68FEAE41C374BDC63DE
Previous signature
4B19E483BB44D2C22A91FA4081C5EE068FF4FE722F9594C718306571B0C3EB8A226EE07874F1F4F0610C449DFADB9339AF19D2305942849CE64CF7B2CF716B09
Origin signature
3044022047A994DDC76120E4116A92685990672277833C1137428E60C3837A35B06A9E770220401E89405D7E5FAE6894B4B0D5BC24223D740905F75E6DEE886149E4E61176AA
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0048F8BE207917DD13EE561A8A35506183A776A24CC18BE39A3756CCD8DBE87678
Coordinator signature
3584EBD000B7EE54BD764B82D5FF2670444A46AB539C352976D1246ABDE2BE60D8655DDB1DC3D46A8F54C9F9A7C70DCAAAC260C81965C6138C2DD25DC5321E0B
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
3CC54D5874E477C1A27F0657BCBA5C8AC8BF138A95E5FD58273901C9EC0740AAB43DC9AC3DA509664529B30DD5F40837950866E629A4C6C31D5EC84335EF6D09
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
6518CD7C7909D38BB2ECAF85199703081ABEC61641957793EDE2A63D1E5056220F1262BCC6A278B364709096AE7E83AB6A0B6B6A3647D3601C01BE33EF06200F