@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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 3
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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 3
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: 2.991
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.009
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 2.991,
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
30BFA1C71C05D6AA4A9EE195B3B92948C7C28806357DD8715B3ECF66EF0C16BECAA19B6A1CB156648EDCA10BA3FC1CDD4A992ED20053A08E13D0496A
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00003349...3AEEAt 2023-12-09 11:15:16 UTCAmount 0.41649204 UCO
Previous public key
00011FA99D00FEAD3D43D1F116FDF4F7974C141769A2C1B6C9BB3C50777D6354CEF2
Previous signature
6CA6D82ECB9579A8F01D5017363A92947D7F537981E088B88F1D31FE8149DBB51843D2B48FD61250E0A27BC50391E3F27C2D4A3B09DFAB26E0D0C289521F9502
Origin signature
304402202766E8394A4874E0FF5568D6CAF676322CF3BB6B8B594364E47DD7D3589D213902201C16A7FCA1D0B4500D148B2E1E90257D785BE74A97CE07C00477BEF4EC574B32
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0046FA3833773F865D0F1CB86748B8D297BCB187EE4F723E236A02BA2B1A0F9F72
Coordinator signature
7C157D23C73F456C5075482366487DC402CE43B809B4FFEE257B6D56BAA968699A41426DA152D6273B5AAE54B130CC59AE409A55B200E7595877C6EB59D6720F
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
4898AF220632501D6E6DB0A1F3384C697853A2F1E1B77C46772432E7FFF71ABAEB1F82F37FDA546DFD3874779560049DC4C2F1CD37948A14248BBA4235234807
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
02DE9D5AE40E3DD830DE83B5CF8639BA42A92C12ECCA07FA1401044C38CBEDAD3DF14525B5DF36CA3495278841584C8BB8C7B7FD46D3FE9D1E1289A86761010D