@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: 0x000004BE34D15FF077A60B1FCE897083D215A3C392BF49CFF15030A774FA8FDEEBD4, amount: 150
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: 0x000004BE34D15FF077A60B1FCE897083D215A3C392BF49CFF15030A774FA8FDEEBD4, amount: 150
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: 149.55
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.45
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 149.55,
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
D05D3BA90917EE3977B7C1D987DD8696FBB12D6E7C1EED1F28BE298E7137F12ADCDDC5C27D295B68AB26398F757FCFBDEA86B338813639CCA3ACACAB
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00004C7B...CC9EAt 2023-12-05 17:25:17 UTCAmount 0.42469435 UCO
Previous public key
0001995E20B6BC813D92B5DE00E88BE7D259FD3C1174741ADCC28B0B9364A5D93C6B
Previous signature
15CF288264564E3CE3486A029F8E75DE4F562BC7927FAC8B0FFEB7E96F89E50EBB8421AFECE89E159848A7886EAFABB73CD8E3CB9CCC728D0A79CCF36109750E
Origin signature
3044022010B5902F338AF30BA123B1CD713798AD49FE3BE8E51046D955C605863EF94A7D022020D2C9BD25421B6525D1CD96151FE2F70C385E7971E079A74D36483DD1AF235C
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
004048EB4CFD2E0F496BEE73C82874B91E81801B0F09E597363E67ED9B6D05827C
Coordinator signature
060E7B63004086C299CD9B937CDECF4FEB7789C5D0391A3F48F38721846BC4886F883DADA4D3ED61BCC17F9039842E20D62C307798845F1930F73D4BF1ECC509
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
3D0ED097A3E5BB0761F811815A3BEF4DBD03491A0E652B5FEDBA142319694A37D4026742052740251BA81FC7AFC0F4FC33D01866DC80FDAEC08B97830C8B7B0A
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
146CCB6ACD227C7DF2868EE815CAF8DBF78077D8B54A9BC1308565EA69BECACE0C51B7168E3812FF42DB798BD771A2EA9F4B919C74FCFF013582C21497DAD302