@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: 0x0000F3D9160C94DD20C903E2C7BBC4AA7C607F4DD93A52FBCAB186464F3D8AAEE1BE, amount: 50
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: 0x0000F3D9160C94DD20C903E2C7BBC4AA7C607F4DD93A52FBCAB186464F3D8AAEE1BE, amount: 50
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: 49.85
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 49.85,
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
7264A09913A2A2F74AE922589C106F365F7BF8FA60F3ED92A8C336BC876C7C8B7C2BC0AD9FA5AFE7511132F26E10169EB9391591495ED065B62C8B30
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00007F77...55D0At 2023-12-14 23:23:36 UTCAmount 0.44550754 UCO
Previous public key
000161EEE7813BA5DC5B7FE265CF34332C01C68C4E35CA40F5789321FD8D014E4B92
Previous signature
B585B9607CD8B89A1B2EB59C0E2C08626E35B6C4F0C24E8348051C40860FF26559B6C07563185F9D1F5F1A94213B2206CD28D327977E930629565EBA1D728508
Origin signature
304402202CEC839917D3D242B03FA8ADABE6DF8B0761BC9790D4B412AE5DA627986FE84E02204663DD4330D7603C39B94A88AEC82006938AF47DCB65884FD6D1FAB8BAE14243
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00E30F8BCEDAD665FFC490257BB02CF15761B3398D69EEF716BF1F5371F4419337
Coordinator signature
4B7AD3964E6C5B1A8DF178C1325CA0C24540AF1B132F90867E471C2B47E760D48E3B7AC6DF9EE267EE9DE563D603B5CBD90BE8419558074E1D8BAF293AEFA30C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
DA0A7AFD17BF18E28A64B215F69ED9FA774E012FA3D836DC5FA92F172231D06C93053A57A4F702C1046B54CF2FAA73C6F9AD29F33D3B1E8467E1069CA9DDA204
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
4040329E9AC3CAEE455EF374222B258A48C1DE0B0383FCFBB3AB950D2FA1413F62C3692F9FBE0D60CA163F4505D9282B82EADC04314088DEC3DB441327EAF908