@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: 0x0000A487AD42A5AA666E2021057C89AB92C97513B31EE65DCA76132BEDE148B12843, 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: 0x0000A487AD42A5AA666E2021057C89AB92C97513B31EE65DCA76132BEDE148B12843, 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
C8C3B0B72047BD511206C2AF7613B0D92D93EC80B9B4FFCBB40D60E8FA2D0AF68288648A53072A59651D8ACB53B69A945F1A92C9BDDFBE69BF5C875B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F883...9C70At 2023-11-13 19:20:19 UTCAmount 0.34640774 UCO
Previous public key
0001D73642DAB3DD4C14CA992E8D5B559E0E31C3FE63547EA50692F0F26862883EAF
Previous signature
74D54DF5F850D4BA7531E2A7397F620D3860AE15077E5C4E32C5B92F67D4C1056AD83B65280B6CC0B76BCC83AC18DE09CDC092DFC86FAB2F1866E5ECD264C90F
Origin signature
3044022073F158B73B84AAD2DE53FC0C8F8DA9B47A5FD38ABD673BC6BAF1081B7CA969200220733AE5816AD8A1533E6A8F4B96341116739AD0E777054B2CFE631E9E39357B8D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
006329DA444916B650E0B20BD89CF7E0005684D7DDCF24EA3BFBD4F9BE5A4C7086
Coordinator signature
BE4D578F05C9F266E726743EC35BE4D72DA0A36FFDC195C1AAF4D3AC32F2115B884CFF789F6C5E9E0DCA32522FC64542EA64F9166C8EDED4F007EABBF60CEB09
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
8B601CEACCAAC8EF8B42D77753C5A8DC6B0DB9D0A7AB3C26C559B641BD05AEE0E36F3A031D4D52AF37867C6A9F152D19D7F36C031ED4D4444817A9657A767003
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
FE95FF7AC04B3E68E09B54F25F6F7BE43355F72D91A90DB0A38627BDE27E6562854635BF04FF14AE5E6A32266F2E8220A2C73F79BDEF89A888469C7ACFC30107