@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: 10
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: 10
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: 9.97
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 9.97,
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
A52DFA53B865560A69B68BEC1A8FD9FE1270178A049E0C9B6D3482ED4037A2D33DFE02E8A23EF2799D00EABC11438C3243E89E3F9BF18E82827503AD
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00005F4B...EAC6At 2023-12-09 10:56:26 UTCAmount 0.41344863 UCO
Previous public key
0001B58EF7195BF944B698D68CAEE4223B63262FE006AEBA5C0D6C97B76F12C55A0B
Previous signature
B604E81B21EFB552D746FA598E258A24897B40492E8DA2865A14846FC9D7F8C333298772FE33695BD97D770BD9ED56CA633D4C24413039357737F12384F96700
Origin signature
3044022019C4CA31739E53B17A5D91422A50B40DB179D6AE65AEE7C0C72425748715AD6902200BEA97A8938BB7EF9B199A2A227DE3E427D5459A116B9E8E6089578B1A5166E3
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0091E599828772B9957D087EF946CCF8FF335B57A708156840BC5A2ED0062AB233
Coordinator signature
CF91F7C7944D6C51B3CFDF33D03AFF8BC61F435069360CB902BFA7147277410182D9C5186EB9258A73E1BE5F789C827B8B2B418A1F9CBA2C2D353B096157CC09
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
CFF78EBD72279D5AE1B6B5B8BBA29E1F3C00F20E690E7BD01D7CEAF72BDAFD8E8190DAA8FA571675BEBC72649B4AA99F8F91980328C8A63EF1BA23E6282F4E09
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
C33CDD57E1691F8B584F1A2692E3859CCB5C8517B11E96E6FDB9D2CB92DB7CC15C8F4E428321AB42510A497DE31B6FB5FDFD0E7912997AD60156CBC809E87C01