@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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 12
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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 12
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: 11.964
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.036
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 11.964,
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
066EF8A849ACB6EC0FEC0F54CD05A969D531532682A2CE821F4B5BB1670418D7464375072881AB7C22B5A9BBB8AFA621B6D8E0BF00B421AD9A84E66B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A7C8...1A11At 2023-12-28 15:38:53 UTCAmount 0.40595874 UCO
Previous public key
0001EE9B711BC6DB324325C4B41EF3B6B99FDD63F26B6BE2B1C0220686A829375092
Previous signature
EED80ABDE35FDEDB9453FB4B718CF3EE5FFC4EC367D543C73CB3964DFAE9717DD1DEAC63B6B78E7A31D3199916F412CAABB4533AF02A97B92311DB667E520003
Origin signature
30450221009E490272E74BBEDF3864827BE0792D316790F2DC95B2935574AA4683B137111B02202B528A9403CEACD0864BD4D510056331AEFFF261FA38A018998C6BFA3670D5C8
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
001E8CBB150C57E421A6958656234FC34DD602DB2AD8953133E3E5F8AC23721617
Coordinator signature
CAC87A468AD33A142058709B36AC151B0A21FE37B10C48C634EC90D82BA02B77E98DF093625AA39AA8D2EE1B9A4D4D594C1A3F56169FFCB07493592F9D8BAE06
Validator #1 public key
000134772A943DC0F7038B1BABA39E18841C12DD6682B1B6D1D15E08D7CAF5339AB0
Validator #1 signature
835A0EB2A82669F4766E2E5EC31FD75FCA5376BCD0E83B657844D918942230DDB15A8A09216B4A2C249BEDA4C40A6B0B36D4EF411181A3ABE81814FC0D624608
Validator #2 public key
000103E30584AD8DE66F9E29419D5D0ABEE5A76722C9FD0D012BDDE3A6E2B149C48D
Validator #2 signature
B4E14140DF0565C7F6047F3A7D4A935B11601362E926EE3DDAC28CC6C1D60B34A139B83BD53BD19127E319DDC24D0C5D81C4586155F48797D47CB2A1034A9C03