Wallet Abstraction
Overview
The WalletAbstraction application is a robust example that demonstrates handling deposits, withdrawals, and balance inspections for Ether, ERC20, ERC721, and ERC1155 tokens using the Crabrolls framework. This document details the application’s usage, including how to send JSON-based inputs and inspect outputs. You can find the source code in the CrabRolls repository.
Usage
The application allows you to interact with various token standards by sending JSON-encoded messages. These can be executed using the send
command from the Cartesi CLI tool. Below are examples for different operations.
Depositing new assets
To make deposits into the application, use the cartesi CLI to send a asset deposit to the respective portal. Send this input using the send
command and provide the data of deposit:
Currently the cartesi send
does not support ERC1155 deposits, so you can use the cartesi explorer to send the deposit, so you need to run the application using the cartesi run
from Cartesi CLI command and then use the explorer to send the deposit.
Ether Operations
Withdrawing Ether
To withdraw all Ether from the sender’s account, use the following JSON input:
Send this input using the send
command:
Now you can view the voucher in the Cartesi Explorer
and execute the withdrawal.
Inspecting Ether Balance
To inspect the Ether balance of a specific address, use the following JSON input:
Send this input using the curl
command to inspect
the application:
Example of the response:
Using the command cast from foundry
you can decode the response payload 0x30
:
Returning in this case the balance of the address 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
.
The value of 1000000000000000000
is equivalent to 1
Ether of balance, you can use the cast from-wei
to convert the value to Ether.
Returning the value of 1
Ether.
ERC20 Operations
Withdrawing ERC20 Tokens
To withdraw ERC20 tokens from the sender’s account, use the following JSON input:
Send this input using the send
command:
Now you can view the voucher in the Cartesi Explorer
and execute the withdrawal.
Inspecting ERC20 Balance
To inspect the ERC20 balance of a specific address, use the following JSON input:
Send this input using the curl
command to inspect
the application:
Example of the response:
Using the cast
command from foundry
, decode the response payload:
Returning the balance of the address:
ERC721 Operations
Withdrawing ERC721 Tokens
To withdraw an ERC721 token from the sender’s account, use the following JSON input:
Send this input using the send
command:
Now you can view the voucher in the Cartesi Explorer
and execute the withdrawal.
Inspecting ERC721 Ownership
To inspect the ownership of an ERC721 token, use the following JSON input:
Send this input using the curl
command to inspect
the application:
Example of the response:
The payload
field contains the address of the token owner.
ERC1155 Operations
Withdrawing ERC1155 Tokens
To withdraw an ERC1155 token from the sender’s account, use the following JSON input:
Send this input using the send
command:
Now you can view the voucher in the Cartesi Explorer
and execute the withdrawal.
Inspecting ERC1155 Balance
To inspect the balance of a specific ERC1155 token ID, use the following JSON input:
Send this input using the curl
command to inspect
the application:
Example of the response:
Using the cast
command from foundry
, decode the response payload:
Returning the balance of the token ID:
The value 10
indicates the balance of the token ID 256
for the specified address.