@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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: 1700089020 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1700089020
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x5401EBA2406E56F0CB0EE591F55113233D426972DDE2CFE1E48CB938FB8BC98D,
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: 0x00002058D607CBF792C23CC2389F4785D54ECBC695EFABF8856BBA051252962DBDE1, amount: 0.04960075, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.4925e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
DCD414E4409BB2E6581F634C362EE837C46FAEA47728F6CD097A3F93275CCB33A737DCE9685F650656AAAF4007D4E4AED92B368B170E237E453AB543
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00001747...AEAErequest_funds
[ 1700089020, 0.04975, "00002058d607cbf792c23cc2389f4785d54ecbc695efabf8856bba051252962dbde1", "5401eba2406e56f0cb0ee591f55113233d426972dde2cfe1e48cb938fb8bc98d", "0x822b25ec2ce1756c5c54d8ccdb379ae7bfa2cb17f237db1de7ba76b71478ba93", "0x8f170eefc3c4af4f7fff2120c05502712ff5d1dc", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000BB23...9072At 2023-11-15 20:58:05 UTCAmount 0.29722486 UCO
Previous public key
0001E0ADC53CEAC5F2F9D28E5CD12837776180A5974939AFFEBC06D72C358CED5DA2
Previous signature
18893D9E527D820636FC8791DB3BEF49254EADAF1C9FFF1191E5D8FFAA256CD0C986234C7B2FB4B41D2598C741E87EFBFDE24E67710D0081F384E4EF0C18BC08
Origin signature
30440220694B36B5EF45C28D9227F2BCCAD2F33B118607F3C21D19F826533F03A1BB42A702207FCD85BF3DB4E0E0F47A87273103F7144211E95F39C2E2DBA95F5D8163FDCDEE
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00A422DBB119DD1A395152B215DF639EFC726FC185D3CFCB43BB5548E843C5607C
Coordinator signature
F7FB26698102BBE3F19CB6F5EE805C078C6C6F3D7A934044E9E552D11151190843CF6C0AFDC5D7A4A95B49ABBCB329E70CB9400A00E0C7B3FF1C69A2FDE88407
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
45A487E65EDDB477ADE138A8D9798A1C4A6098690C124FFBC8255178F4898129639CB755ADF51611D80FE510D4E2A7F9B1D737CF50EEB5534752C3A7369E6B04
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
AFB2A4E0C46B00D28E77B457F58DCD13D755CAC6FF93207A7CEC649D91DEA3E46A1E6C9090EC53B2EFD60A43E64119DB84D0753E0B0F3B3DAB16031155238805