@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: 0x000079B40CB20AB1624178169798B0C9D9245BE746399864BE620B3099689DB824B9, amount: 5
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: 0x000079B40CB20AB1624178169798B0C9D9245BE746399864BE620B3099689DB824B9, amount: 5
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: 4.985
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 4.985,
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
7FBF78301D77D996E61B8C9FCCA85A78BB4191C2CD02B59BC50300114068261977F17240992D3E174679FDF4A05A152F8B3B240453AD9FE33F0ED3D6
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000DAB1...364BAt 2023-12-01 09:18:48 UTCAmount 0.40538393 UCO
Previous public key
00018D4B3C798243829C0719AB6D6269E063553E539AC52D5B8B283B3EAAA7BE9596
Previous signature
56935AC006F03BA46D8A38DD2C256C7BD2880F4FD069389BC8BC9EF4019A58BA7B642BA80F9D1F8ECD07A0B2B2F24B89F076AFF94AAD7E0E67A5E07ADA82FA0D
Origin signature
3044022060B34B3C4988D96EB732DAE9C8DBE40F16DC6D7F36C9D8E2D9774D4CB128BAAD02200F6F9A7D4E73ED49B3571CB22C061C9256E49F53BADFF7DEA92A2BF196083F1D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D6649F59F7C5E549CFD43DBA599CEC828573C9262EF1A03CDABA9DC09CB80D49
Coordinator signature
7028EE0EE60EDA3A1E8863986AADCBE1484A731B5883225ED1CBEB66FCD2FB7E3FEA3AA83F223363036FA6DAECB2430F032C6C91092002E9D59AE82FBAA2F409
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
52DF04572C415B71A1C294C68CF8329E5252598F1AB881F551C4A6ECE413C686F1CEA02238E595F47C1C910827445E15BF004353317DE9FA401F68B5C74C980D
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
3452546D7349514FA8C0FC716962C1C8AB742D992916F616077E12F45509FFC2DA27A03E4277A2F4CBC1D962F0EFC56066A0A79A62A016FC482A7800C0EF0406