@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: 0x0000064F114419DD1BA0B495E4B596513A180BCC4F58643496F0919DCC3B6313BEA1, amount: 1.0e-8
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: 0x0000064F114419DD1BA0B495E4B596513A180BCC4F58643496F0919DCC3B6313BEA1, amount: 1.0e-8
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: 1.0e-8
# Transfer fee is less than the minimum decimals
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 1.0e-8,
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
648EAF985792CA578BA7EC11B6C6D69160EC1C983869E397ACD0B635FC726D99B970807029E2E5E70013F3C651D2C196FCFD46BDA2BF8DB8D884FCE3
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A1D5...C894At 2023-12-02 19:58:13 UTCAmount 0.41633708 UCO
Previous public key
0001329E3A0BBB70CCE8422C53E8382C5DCCDC392A810123CDADC4B9AF549F3C5343
Previous signature
6E851670E6D619F2EAEAB2C04B51E6401E7731918329EA1B20C0D4426384D2C4D7E17D7E1FE6ECC1DDA99BE6067BFB58DC6EEEFA2DD01DB79F02EE346FE3AC08
Origin signature
304402204BFED78ADA524AE462B08A62A2CC822B4AC3D807C75CDCBC97EE6B07B1D882D602207C9F3458C761C2ADBE3482F45693223AB2E4DE707FF4E1AD3880C1FE502FBD1F
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00DB56859091A31321BF67EE44596CBD7EFD2D9D590E0958CC506CF41E86520E33
Coordinator signature
2205785D0C21CBD2522D73F22BCCA2AFCBF0508F795E85C6D1362F7B5CDD678AD04CD94D5AA056D074A5F8720399CAFE1C03E10F16B375B0D5E5D616DF6E9D0F
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
0B39677D265231BFC8AAC95BCD38097C9E0E73502B89423E8D270F0FDF685B7A9C753E0389189A05204996C5A1AFB18366FDB9A6B0286B321AA9A19E18CDDD05
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
E1AD50C9FD1AB4E6BB4AD8B55B75572DD9957A2C24C5D0842443DBD756374910DBCF7772A3E754B2EC8E21C06323D1B5FDC41530E00E14BBCE48D51CD40CAB0B