@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: 0x0000CB30ACA5320066B4413E9D4190EA13562F3225BB5F49A975ABD91CFFDAFED88D, 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: 0x0000CB30ACA5320066B4413E9D4190EA13562F3225BB5F49A975ABD91CFFDAFED88D, 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
0245296E47D6D2E7BE7F394ABBE8197AF3E897B7DDBCCD8D46FE3D77B4CB56B4A8A7B36A5B7ABE0E51F2781C3CB108C9FAD0B14442D74EEFDAF17E8B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00001939...1534At 2023-10-23 15:34:02 UTCAmount 0.5999007 UCO
Previous public key
00017B6EC86E4FA375C673BE58434BE78EB66B8E6097E0454472A0FA8EBB4A474237
Previous signature
4CF2D263558DDAE018299AD10A8438F65CAEA42B13CB147CC18FF7B2B2E495837A7FD7B21977E2702DFE56B6BF224732FDADA1E1B00CFD7327F0C6280F878405
Origin signature
30450221009BF9A261A0CC23276157A7F7BFB788BC7B1F24BA26A8E848500EC1422303F7D7022041BE3F66A972D32FCC9E4D2A425635996992DA107E0682A69CC757B2EF098BDF
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0084F13C8284A0635FFA279953E37C7F97B64A2BF31A19A24CADE339EA27A9C10F
Coordinator signature
C939544ECEAD255F7097BF74CCB0714752AA0203B3ACEC2BCE83DC65C7DD1A86BAED939FAF58C0E782691D33575B981C60BDBBB25A8AFF8BD3C07469CA41670C
Validator #1 public key
00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC
Validator #1 signature
2D4F48D0E36267F56355D49B2EAC52CDBC4AE0A8D3DE5A3A04CD2EE36BAD483ADF684A0485B0FD03E0EA54CB699EE147EE3896840940F334C97D405B1A6A5502
Validator #2 public key
0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34
Validator #2 signature
4350B22A1A72B3D371AC404FF310483C195DC677B7DF30B0360B317977C7E29DC70B5254725126D37C131FCCE99BC9D583A8826D7E077834BB5A4FAF9F21720E