@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: 45
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: 45
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: 44.865
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.135
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 44.865,
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
AF631697B9DF4746D7CE5118868941A94A4D2F4B6E41364C423BA319AF900D56700212E3DB22F21B1D1135B3D6FA1DF951FD528D6DFE74B9C8BF5F8D
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000DBFE...1DA3At 2023-12-28 12:56:59 UTCAmount 0.40358006 UCO
Previous public key
0001468026A1642C40EDB4B7BFA8CA20EB913B09E0B326B3F2E5035C6B1DBC6A5CD7
Previous signature
770D14341EF56BD795F2FB8633BCF6344B51A02475D247E855306874F46A79A7D163EB56B99EA183113C8C81DDC11D325138773EC3302FF379BADB892E2A8D0B
Origin signature
3044022014E31E6C0F5D20579EEC52905DDE6ABD4922C949D295D2CEA0CDDA8A44DE31FF022071453490A59AA7A08DE317FF4B1FAE01894DB1B78D75F7826EDDD268CDB378E0
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00A76F21C9138027DA2AF5D719C65F13D19213456EE4979C907256AEA570559D12
Coordinator signature
CE9D8CA382D032E76A9AE5F05194496CB5FE9E995FD4639CE2D49F0863E6739958D79DC4B1488D6DA38DF228AF6922D4E5F63E2E065C6218B0049711BA044E03
Validator #1 public key
00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC
Validator #1 signature
01FEBE2EF8FDEE2FD476A86895E51CE18A17AFF9C6B0C4DFE023F0BE32063BC86214D5AF64A2F458322809364770B7516DD0565CAAE25AA402DE9752F012D20F
Validator #2 public key
000177BA744AC778DC2D51A1B7C622E7AC4BD1E1AA8DA2D0FCE71BAAB7DAD0E020E0
Validator #2 signature
608D3F237602C2CB264C295A19CA2C8DFF523D4D6D7987030A73744500A8A3C98CABE048303BECB78589CFB5C269BC3BED6DD7806108B5C496F4B63FFB3D9B06