@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: 0x0000049B40D48659C2D4C14CA2DD2C35DD1C01F74481243C24687FED5A53C540DD8F, 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: 0x0000049B40D48659C2D4C14CA2DD2C35DD1C01F74481243C24687FED5A53C540DD8F, 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
DE62F517AF6FDB75335AF1F2F3FBE77B193CB4B050F2D9EEBA0D5BB83F417840A9240D2F074296F3F50509A8CD8053D5D813343886BDB2997FDAB570
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000087D4...6EF8At 2024-02-01 01:29:00 UTCAmount 0.45413467 UCO
Previous public key
0001393B5DA6FDB14FEFF0A7830144E9F13DAB78AAEFD2E6CACB0F1ACAC6EF98A607
Previous signature
B221E37038C1FD13CB8DD16BEC33898C8133A19D2AAA5D5DF01F9FC5D42625BC9FFBD32F294A53CBC09B741255C60D9D5FB852E3BE29AECC3CFD3555E0628209
Origin signature
3045022100A0EB9FB984F6E306E27B3C1156FFD245EE9B24ECD4D9EDFF7EFFBE402E747B17022055B2E7C5907FE33F36C5C94FAF4B30E3143BB862E857BD490BA3064429C87C89
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00A0E57D1B7B17FC93A1453BD186DA391CCA0EEAC0C7BF60E7FECFBE87D09A1FAE
Coordinator signature
1C1E21C5AB2FF5C1A0C89BD044B9DEAACD0EE9572A55D161F9E2E4456C267FF5F8935B545F63FE51E4BCCC19412CA4F6F24ABB2EE5193036A74343AA7F711200
Validator #1 public key
000177BA744AC778DC2D51A1B7C622E7AC4BD1E1AA8DA2D0FCE71BAAB7DAD0E020E0
Validator #1 signature
1CF91461A2E0A916F2EFE5A2F0BDB8547064525F3AA77706BBBAECE127812633F781FD0BB1C72D67F45CE16930AB6790D06973000AFDF6288777890931F98A0E
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
26844118AD0551DCE519F4BB7E547E1F686329D54E984C72EE4B6A05448BA34410B53571BD0245454A4D61A2D3CFBA06948DC98F90573041D2761057FF17CA0B