@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) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
)
]
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_token_transfer to: 0x0000B57F380A6FDD0E091BF06894748657AC79686AED964A3F2A9DD87527632F6AE3, amount: 0.2, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
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_token_transfer to: 0x0000B57F380A6FDD0E091BF06894748657AC79686AED964A3F2A9DD87527632F6AE3, amount: 0.2, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
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) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
),
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_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.1994, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0006, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 0.1994,
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
4E2C229B5816E710148761F1A2DEF3C7EA6465E72E6D9D5D42934AD187DB81EF3B1C48721585A6F60B252FAD3D653296161C6E102420398A30AE6614
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A30E...2199At 2023-12-05 16:17:23 UTCAmount 0.42741148 UCO
Previous public key
0001BF0C6BA4AD8E0D34CF9D7BDC3FBA89D78FC985233DF3B544DC36C21EFDF1A3D0
Previous signature
7A9C5D30835658615C5F0DBAD2915AAFD2E12E7000D6586EE9DEFC60007C4FC0C15BC6232F9864C59F9680D083120937AE3B48E9990BDEEAB5AC6286414E4809
Origin signature
304402205437143F8962564752C82FE432257154A37DC63E7AB1C6F91F9362D221D45D6C0220538087744E79E7AA42C50C4973A0AA5D1A612E0C34DFB2B8CB66C8F59569D5E7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00084B6A8579A9B9257872763B7058828B0A3F3C24C887BF76B6151A15C3390D7E
Coordinator signature
48283152E893E809173A1A30D27874D6E3366E22684B76D116DA5E5B5B9735202F72F30D526944F84CAFD2CB64F05853F544DD664E7292BDBEF98DD8F0078208
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
978B292322BD82A4B6BB018A03DD90B5D800ADF12B5A8CA8861ECF312FF9B0599A712652414F91420F29824EE5CE4EEFBAAA7F454D17D33E0BD7F2EC23B2F007
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
075DCD21E264AAABD932B3B251804F4DF6355606078F70D1C39E0392682F8D3ECEF7C06D9520B3414429D0A26B7B238C8E7C9E4D4DA885BC16FBADD0CADEF108