@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: 0x000079E07D373D5DD653A6F406D38890A6EA8DFE20708C323B3B576AAD469DCA9984, amount: 20
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: 0x000079E07D373D5DD653A6F406D38890A6EA8DFE20708C323B3B576AAD469DCA9984, amount: 20
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: 19.94
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.06
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 19.94,
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
ED8D62724DEBED4F1575B8A73B8CEDDD5003242413B1DA79C9D4A95266D0201F5C99292CC2F4C5A0E7CEC11F6F17C8DB001F6F4C9ABFB8718F3028C5
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A788...6CEAAt 2023-11-30 10:25:49 UTCAmount 0.42068727 UCO
Previous public key
0001835D233ABA444D2BDB89922780AFA1D148BEB71ED849E3FB60768F0CBF735757
Previous signature
CEBCEFA459002E09C362D257AD5B491DECD0D35DBFB13DEFE44A53278AC68B984D7D5FCD859FB675498B5C3CDCC4E09ABCFF6C40B44A60F2D0C2774FF69FBE02
Origin signature
3045022100A847142C8CCDB6179894AE88B196AEF48994EFA42BC641CE4748261F2A84C2310220183850C5F220F4770CE80EE847B3F2D9F3656EBD39F1D02583BB0FAFD70C2F32
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00CDE8C1D172AF9E85BAE79AC7168FE3FCF59FF4355D348BA81AB8ABB90FC190E1
Coordinator signature
AF13A726098601F06DCF4AB19F3389FF99E388C03F19A0BEEA9AC04736128729EB8CCC0BAFC848C1447F13B4533B3A14DE648D649AE64C2C23C3CF8B7DC00001
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
B4EBB96C2100304D729451606313C010EDDF6608B5B1531280AAE7C459F4E5BD1F85480D0D855AAA1C4462D15ADE5D5B34EB834E258253111724D5B42D71A309
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
7B5168B524FFAA8D28A3D66D936528A1509B2C88071663EF430EEF62EB5B4047D1E8D645D88ECC35A9BAD7CAFADE49406B874962227894B6C29C4018DF2FA206