@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: 1701768660 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.010945, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701768660
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.010945, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xF1D6339B8063508B0EFB70567BCC8F245501761D5AA3A835561AF8C06EA7E085,
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: 0x00000BC0EBA2DBCE4455B46F5E51AFAABA6EB4C7FBA1D4E2E6DABD55DC70F9A04D6F, amount: 0.01091217, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.283e-5, 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
D61D0ED4DAF67AD41FBC7764BD2A5A3BF685B9EF59C882363592360EBA6201AD2477B7191898BCA39EBC847A1A7CB571D5A4605CA92ED57738929F29
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000BA80...D876request_funds
[ 1701768660, 0.010945, "00000bc0eba2dbce4455b46f5e51afaaba6eb4c7fba1d4e2e6dabd55dc70f9a04d6f", "f1d6339b8063508b0efb70567bcc8f245501761d5aa3a835561af8c06ea7e085", "0xd2c21ed992fc525c781c9dee1f34fa0b85395939f9aa284eabe1c490f0cde60d", "0x0b2b2a5bd5b4df6171c21c80624832f588cd24d6", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000AAA0...692BAt 2023-12-05 07:31:19 UTCAmount 0.36691135 UCO
Previous public key
00011339E96D89357A39F99D031369588A9F75FFCBE17E6BA2A36BEAA7BC19C65AAC
Previous signature
0A0E927089753C45CCA482516021BC90710D36C0EC6B82C72E8FA60A84A0DF522C371B1C66A1FE3CA9EC08A121A0E986C599EF63AC64FFBD1EA4A7D1928BF607
Origin signature
3045022100D83FBFC0787259C3C829A96455672AACFD444687C5CB065B5886862216C2511202204630E50709E45D2DBC439BB4CFD07B3C3E6434A544DB053CD620156F0414EDD8
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
001FD142635F8D64DD3E5ECDB6247460D8B0D299F22CE0F27FCDE718434A56C27D
Coordinator signature
2A35B3219A1F82D361A5DA6C9F267A34DCCD6B54B6ACE473946F4290BCB6DEFECFC642B6447A1276B0F7E1D366454016243CB0BEDD79B476FE252C2265F8E10A
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
F267DFCDC5A336CE46565DD874783BF2385FDCDD90F9BF9DA90F9652E4F30E34BF960B7E64CBA838BC694946EA61AA24CB8FF6E261C97AAAAF6E02576CC21608
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
B80C4474A22142F7B687A95F1B33D15101C38A2A6D023EE380F120AD2A316EE7B99AD373BB2C3391770D3C541343AC12571519AA34B93F1A57EA2804171A640E