@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: 0x0000B82D5EA42A09C85F8D358D92CC0CE6BBEA919FB66407691B97F021598610F2B3, 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: 0x0000B82D5EA42A09C85F8D358D92CC0CE6BBEA919FB66407691B97F021598610F2B3, 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
049438879C896BC99D2B12CFC5DBCEE1EC16B5122EDBFEA5CA545CBB2F71B7BE631975FAF0D638F5F2B604B028AECEE9EAA3C51FB81D78ACB8E184B9
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000067A5...1436At 2023-12-05 17:02:17 UTCAmount 0.42523564 UCO
Previous public key
00016BF4FFB1E60B5A0B8F86BDCB0555DBA0A1BC1AE67619CD614A4A9229EFBE1106
Previous signature
792531D0661E36B708372B777D1F4007B719841DEBC14DA406B0257F767787B36750F35580C81BB662CA1F3B08547D73ED273C875A8F43C09F2B729882933503
Origin signature
3045022100A52B8C9324F5724D71136B4AEC08DB6CFE20B14072FBD0698039E31543DFCF5F02203E20E9333F5B03B47D4F1B2408E8026F26D566BF346B8645877D668E4B4D204D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00953086CB40BDB971C6D36B1422370654A2E9FA097E3013FAE46E4111A916AC04
Coordinator signature
4266B84C6130BF26B7B68C9098E76F7F0022EEBAB466859DF22D43D303F6ECDF509C8B7EBF7515C3002E2D39978690B4D2331799BBA28D64FD6908A6B0FF3706
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
DDA8A5F7BF43106A4ABDCF8E7E72521B67760D92EF89E2D1A2BFC5928609BC16163A3F787B86D947B717AA4CEA29E4F0F0EB254157E67F9FF244717366A2610E
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
D9DC2340916A452DDE51EDEC60A76BDB11B591DBF7216F94D2C328AE8F3D0C89D04B34CD9AC1B1C745E5BB3F5CA6A0300F5B1F09E6430F0C818366027E2D1102