@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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, amount: 150
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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, amount: 150
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: 149.55
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.45
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 149.55,
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
1115BDC009BB48F8D0E016AB6657652F2C7838A8B83B8E0C54DDAC90172B9B4F063F0B7178F8D4FEC7C97BACEAA7ADD2F0F0D03E0BB807298B065825
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000DD1E...3218At 2023-11-30 14:29:45 UTCAmount 0.4212196 UCO
Previous public key
00017DF01E195F8074365893BB45E3DB810DF758633A1B6B08178D7184973D5E8D6D
Previous signature
750D2C2C3331786F0517D60EB97B5C00E000375450E1C02BFF84787BAAD2BFB33D35812960C9BBED0BE08633615D240FFCEA6FB2B58F157D3AE7959A904E160F
Origin signature
304402207C6C68002E8F4F8241DF471620691B56C75662B9537B1F1DFB4482290F793AF2022022F93C4467C3745754440E661EC39C63C9AA02E6F015296C792F909BF0F13CC9
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00A16A91F9ECFD9025B2FB6B5506DF3D9B25400C0D35721BC8A880CB220A470CC9
Coordinator signature
84A2FCF7E15F16CF57FC8B979E44417455D51CAC08F4FBF0797195308B2C135BDCEC3D4A9623E1493A078E54E4817231E74EFD42F6DB5576BD6BECFF681B9E04
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
116AF91273286798391E8D41AD132E042B4C4A0A4D62FB197870625A18DC7EA992E3039D9E9574B388190E60E6864335632A008BA8315EB6B12338EB81E64E05
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
615B0AA2F46C3CF84D55209D2A20AC4B0EA7A03BD6904776A2F73AF2015322D224C99588E9488DE90303DE93DA8582DB15EE9B28023A53E23BE52D26DE56430B