@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: 0x000024BF9D5BCBD7F48E4EA13B91004B20B71CC76611A12A74FFC29809EB3C1FF2F3, 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: 0x000024BF9D5BCBD7F48E4EA13B91004B20B71CC76611A12A74FFC29809EB3C1FF2F3, 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
007C8E993B15B6B654B8CF1A889857C6FD09D1583A9DD2427DE45F06381D58AD5C2FD23B9255244C3A97635F792079ADBCAE19868A85649AA9F41D66
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C91B...A504At 2023-12-02 17:03:32 UTCAmount 0.4241055 UCO
Previous public key
0001E0C90C7E4AF5DFCFD9185E2F562C1A27BDAC32BE7D2D3B5E4DA668999B9AABDA
Previous signature
0D20137C610EF13782828756714E31D8D4DE34741D8DC6F725AE3DC1E344DA6B377918C13E0946B550E5488C5511B9A1B7169CDC5796BBE147F3B7353933820A
Origin signature
304402205C95ECE6A2F5CA0C2F39B387C89958BC4A48EADF30ED026E67D4C7DF538042A60220778C3FE6CE532310D1C341318EA8CB7BA2D73E3E99260C0EAECFD688722199B1
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0084B7AE3CE6151CB30D2B60290B336810CEA433FEC3CD0687D71B39A02742ADF4
Coordinator signature
8419DB116BB6282044290FDFA72D4F6189AEA2718B41B368EE08502F8A4CB6D596549FAE97086669E62535DF23EAAD4F59EF8115F21503DD0FC0B58916557E0A
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
937DA00EF24A6C9D65600D02B4C37222B86CB32464DC1F363E8D33D093AB83FB0F4052F6FEB71B4A23E1CDB26D321335BA23F009C28C2EAAD64AA2625575A20F
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
3605F8AACD8CE8FF204D2023CBD7BCE52788F48CDCD7BFDEB0E6238D78D964507870D66EC769D089E25BB9BA8478C833C90B3D952815C681585CA7CDEACED709