@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: 0x00001A2439CE855DE869487DD28EB22E45767A11AEAAA59A2FD7838C18BB80DF1871, 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: 0x00001A2439CE855DE869487DD28EB22E45767A11AEAAA59A2FD7838C18BB80DF1871, 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
7BDC405D9FF61E7BB059A4AB011DD64E564A8E7327801569C8111B684CE35D35E89FB3E50BCA2FF2F8039E50D79E03CCE67CB8DBFDE2391789BE44CB
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F34D...26F8At 2023-12-02 15:09:45 UTCAmount 0.42558598 UCO
Previous public key
00017629CDAF1A68D3B5A34CC7C4229615B53A8F818A40A213ECB21A582DC158BC08
Previous signature
7C855482CD05392C0DDB47400F7B5532D931F9EFB483993788F90953ADEFCA1F624B600EC9DE55419EC06B91EE4EB96EE2AD8DF77A2FCC7326714F2A642A6E0A
Origin signature
304402200CAA4B5137E5B8A256697B3248FE7E4E62FACF22DC2B35D4407C6687B7811BAA0220301C2F2064A82E5202D64CFE47756EB2C203B7A3B17C54F9522030CE482E3504
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00F4AB7BEB3936FFF5CE63DE100EC6FD3D74DDFE902A99ACD89CAE6F8B949545B4
Coordinator signature
6AF3D9C1D6A0C18719BE8ABCF2AE9707A105CFCEF64967F93FBEE87C42385C3E3E9FE0DE173F45E736B46FDBA06481D26EE6B58D03F2D0278813A5E14488890A
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
046370A69F204D765AD77F5FD31BE2AFD6C11FE8CBCC346E69214C4D8D1291A13DD18A211F77C3F013B6CA1525558109929D33667A569D582ACF9367666F3F02
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
D53C5935E8BD3BF506FB99D5CD96E8A657E9DFAF82AAAB0D7DDDDADD1385152B70A277BB64D7FC732008EB143B8EB4F3B97AF9032CCA1FF893930C607964D50A