@version 1
condition triggered_by: transaction, on: provision(_evm_contract, _url), 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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]
actions triggered_by: transaction, on: provision(evm_contract, url) do
next_code = """
@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1701862620 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0199, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701862620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0199, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x1757DCB5B879C9EB3D2A99C1C3726623A6DD2C092AF33EB05D9055B66CA8A11C,
address: (
valid? = false
abi_data = Evm.abi_encode("status()")
tx = [to: "#{evm_contract}", data: "0x\#{abi_data}"]
request = [jsonrpc: "2.0", id: "1", method: "eth_call", params: [tx, "latest"]]
headers = ["Content-Type": "application/json"]
body = Json.to_string(request)
res = Http.request("#{url}", "POST", headers, body)
if res.status == 200 && Json.is_valid?(res.body) do
response = Json.parse(res.body)
result = Map.get(response, "result")
if result != nil do
decoded_abi = Evm.abi_decode("(uint)", result)
# Withdrawn status is 1
valid? = List.at(decoded_abi, 0) == 1
end
end
valid?
)
]
actions triggered_by: transaction, on: reveal_secret(secret) do
Contract.set_type "transfer"
Contract.add_token_transfer to: 0x000030FB5F841975E6CB65DB7DE66DA41E39D96CBDE0BDBB781862D7F1B5B7088098, amount: 0.0198403, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.97e-5, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
D6201BEA0768705AE4B458715D51F7DEF658105631B32ADD21C39BFF4E7DE9B8328CEB65CE3472085280B5C1679544E2D1EF0E746AA09AC165F17346
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 000056B6...F98Brequest_funds
[ 1701862620, 0.0199, "000030fb5f841975e6cb65db7de66da41e39d96cbde0bdbb781862d7f1b5b7088098", "1757dcb5b879c9eb3d2a99c1c3726623a6dd2c092af33eb05d9055b66ca8a11c", "0x3cfce2be3bd6741e279d730c5721c2f26dca884382b3d0c647c221841fb13d90", "0x92078a37088f26e8a54fe334d6653ff3f30feae6", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C1E2...31CEAt 2023-12-06 09:38:16 UTCAmount 0.3713013 UCO
Previous public key
0001EBD443F21D1B120863CEB15E85E29D57C825283732837C63AE527ECFFD38A1BF
Previous signature
667982383E3B9E2646D87104D083BF7A8029DFACBD13F97FC7FFCE3CC34048E000FD0D6E0161DB17CCC964691EE6D8A6F634A432A16DD097D48A9EADE651650A
Origin signature
3044022061F4695A4AC9FC837D1CFB95B0B55744068C5E6BBDE1E1876BFD3ED7F48B9B04022037A212C5E4AF66AA5CD78A68AFD380B26438865EC00C3E0D5D00FC722140187B
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
000481457DAC8E5187B3F4DA32583CEE743574C510058BD123E9E36858EEA106DC
Coordinator signature
2AA8632B5A1BDC2EBC95E86EB05B43491302D26D1C12E3A9E66B1B3347E340EF850E3E51792764327BCC9B30BCA0A35D907FA9073C33333F7D6142E709FDC202
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
073EDFBF8F75075188B20ECF37E6D0156C07A6CB6E0E7B57BAF21EC9EE51D101A0ADB94CA8DBE063118D6906C732BF3DDE063633C83753618B8B2974BD81400B
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
F18D7AF6D451644A5A7B49DC4E45F2E67EA0907028E53465C78BC55235242B959EA13E1E66BE62C455882E4728EE8542042AB7DD3110B79EFFE273BB8377CA0D