@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: 0x000042FCDBBA8C9DEA1853CD257FE7E183F8306E313B0B2DCBA67EE45C42A645A47B, amount: 5.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: 0x000042FCDBBA8C9DEA1853CD257FE7E183F8306E313B0B2DCBA67EE45C42A645A47B, amount: 5.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: 5.4835
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0165
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 5.4835,
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
82BBD58EE293C7FB2997E9A73D1FF8B483D2E91371BD6973CF2D80F0D9AE7D4A648D56DFB8512113E5300082FD347B4E255C17E110C96305A1F0B705
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00009773...7E75At 2023-12-14 04:23:22 UTCAmount 0.43853904 UCO
Previous public key
0001C454A13E492381269FFFBAA72D86D0FFF2268E3437296BC050EEEFCD9B45F837
Previous signature
94BD5786D9FCF03BC0392EFCE9AE8AF6C5381D9E03CF345F02656D61EC31B822A80B488F68368CCE196770947865578B17B2F2059CE59932D13A00A72A986800
Origin signature
3045022100BE10C2EFC5C2AEA2EE1A98779AA6D57F7219316714D26CFC24373AEA81F948770220438E55C20B2DB30333ABE4F37E650DEF56754E10D4272ADD3AF27478C65D1499
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00640E628A598E38D1C3EA489E6ABC299E47C609AFC87F17681D1FEB4A35343672
Coordinator signature
D1D6463E835B6184F69CEF31424EAB2DDEA3112113C281CEC5F4E1DE16C6675A04A8FCDA847EC18C3DD72FEB79F742846B827D05B2231448F2821371F36B090D
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
586F4CBBAC0FF47DA1B885D7157F84A5E5148B11F43157103F75233D586B97092946DB40252FFFB0D0575DEC4CF3B189394DD539D4FE05E07366AC2AEB412D0A
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
84A05118850FCEAEEB0874F46C01A767BBB44A5705FFBDA89D89550C619161B8F236174D72FE44300CFF6AC2C35EF39C6299A8BE88C611821EB5C77FC619AF0D