This demonstration will encompass the following topics:
- Initiating a local Avail + Optimistic EVM Rollup development network.
- Establishing a connection between the MetaMask wallet and the Optimistic EVM Rollup chain.
- Deploying and minting ERC20 tokens and NFT tokens.
- Importing assets into the MetaMask wallet.
The examples in this guide are for linux/arm64.
If you are using a different operating system like macOS or Windows, you can set up a Linux environment in a Docker container. Here are the steps to follow:
- Run the following commands to prepare a Docker container:
docker run -d -it -p 22:22 ubuntu
docker exec -it <container-id> bash
- Inside the Docker container, run the following commands to install necessary dependencies:
apt update && apt install openssh-server sudo unzip curl jq git vim -y
useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu
echo 'ubuntu:ubuntu' | chpasswd
service ssh start
- Install Node.js:
curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
apt install nodejs
- Download the Avail release from the Releases page
curl -LO https://github.com/availproject/avail/releases/download/v1.3.0-rc3/data-avail-linux-aarch64.tar.gz
- Extract the downloaded tar.gz file:
tar -xzvf data-avail-linux-aarch64.tar.gz
- Start the Avail development network:
./data-avail-linux-aarch64 --dev
To set up a local DevNet, follow these steps:
- Generate an auth token from github.com/settings/tokens.
- Save the generated token as the G_TOKEN environment variable.
- Run the following commands to download the Optimistic EVM Rollup binary, unzip it, and start a DevNet:
ASSET_ID=$(curl -H "Authorization: token $G_TOKEN" https://api.github.com/repos/availproject/op-evm/releases/tags/v0.1.0 | jq '.assets[] | select(.name == "op-evm-linux-arm64.zip") | .id')
curl -LJO -H "Authorization: token $G_TOKEN" -H 'Accept: application/octet-stream' https://api.github.com/repos/availproject/op-evm/releases/assets/$ASSET_ID
unzip op-evm-linux-arm64.zip
mkdir -p data/test-accounts
./op-evm devnet
You should see logs similar to this:
2023-06-16T12:13:09.921+0300 [INFO] all nodes started: servers_count=3
2023-06-16T12:13:09.921+0300 [INFO] polygon.server.avail: About to process node staking...: node_type=watchtower
| NODE TYPE | JSONRPC URL | FRAUD SERVER URL | GRPC ADDR |
| bootstrap-sequencer | http://127.0.0.1:49601/ | http://127.0.0.1:49604/ | 127.0.0.1:49602 |
| sequencer | http://127.0.0.1:49605/ | http://127.0.0.1:49608/ | 127.0.0.1:49606 |
| watchtower | http://127.0.0.1:49609/ | http://127.0.0.1:49612/ | 127.0.0.1:49610 |
Copy the first json url from the table. (in our case it's http://127.0.0.1:49601/
).
To deploy a devnet or a testnet in AWS using terraform follow the instructions here.
- Open your MetaMask wallet.
- Go to Settings > Networks > Add Network > Add a network manually.
- Fill in the following network details:
- Network name:
OpEVM devnet
- New RPC URL:
http://127.0.0.1:49601/
(use your bootstrap sequencer rpc link) - Chain ID:
100
- Currency symbol:
ETH
- Network name:
- Click "Save" and switch to the
OpEVM devnet
network.
To transfer funds from the faucet account to your account, you need to import the faucet account in your MetaMask wallet and send tokens. Here are the steps:
- Copy the provided private key:
e29fc399e151b829ca68ba811108965aeec52c21f2ac1744cb28f203231dc085
- Open your MetaMask wallet.
- Click your account icon and press Import account.
- Paste the private key in the field and click "Import".
- You should see that you have tokens in the current account.
- To send tokens to your initial account, click the Send button, select Transfer between my accounts, choose Account 1, enter the amount, and confirm the transaction.
You should see your transaction in the queue, after it is processed switch to Account 1
To export the private key from your MetaMask wallet, follow these steps:
- In your MetaMask wallet, click the Three dots next to your account name and key.
- Go to Account details > Export private key.
- Enter your password and confirm.
- Copy your private key and click "Done".
- Clone the Optimistic EVM Rollup contracts repository:
git clone https://$G_TOKEN@github.com/availproject/op-evm-contracts.git
cd op-evm-contracts/testing
- Install dependencies and copy the environment file:
cd op-evm-contracts/testing
npm install
cp .env.example .env
- Set the appropriate values for the environment variables in the .env file. In this demo, the values should be as follows:
OPEVM_URL=http://127.0.0.1:49601/
ACC_PRIVATE_KEY=<private key>
To deploy and mint an NFT, run the following command:
npx hardhat run scripts/deploy-nft.ts
You should see a response similar to this:
TestNFT deployed to 0x8b4cdD710bB9A4f02578c349DB5d1DF7FeFe9343; token uri is: ipfs://bafybeig37ioir76s7mg5oobetncojcm3c3hxasyd4rvid4jqhy4gkaheg4/?filename=0-PUG.json; tokenCounter is: 0
To import NFTs into MetaMask, follow these steps:
- Go to MetaMask and navigate to the NFTs tab.
- Click Import NFT.
- Fill in the fields with the provided information.
- Address:
0x8b4cdD710bB9A4f02578c349DB5d1DF7FeFe9343
- Token ID:
0
- Address:
- Click Add.
To deploy and mint an ERC20 token, run the following command:
npx hardhat run scripts/deploy-token.ts
You should see a response similar to this:
TestToken deployed to 0x282a5B9D1bcD5Ef7445e94bb499A3F9CDB06eAE8
To import ERC20 tokens into your MetaMask wallet, follow these steps:
- Go to your MetaMask wallet and navigate to the Assets tab.
- Click Import tokens.
- Fill in the fields with the provided information.
- Token contract address:
0x256828c8E6CD0AC05FB1f31aFFaf17248fD863F9
- Token symbol:
TEST
- Token decimal:
18
- Token contract address:
- Click Add custom token and Import tokens.