Deploy a zk-rollup in Airchains testnet

image

Save all of addresses or private-keys during the installation

Save /root/.tracks folder in your local computer in the end

Use Mobaxterm client to connect to your VPS (it's better than putty or termius)

Official Links

System Requirements (Minimum-Recommended)

Ram cpu disk
2-4 GB 2-4 Core +200 GB SSD

Steps

1- Install Dependecies

# Update Packages
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git jq lz4 build-essential cmake perl automake autoconf libtool wget libssl-dev

# Install Go
sudo rm -rf /usr/local/go
curl -L https://go.dev/dl/go1.22.3.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
source .bash_profile
go version
# Clone Airchains repositories
git clone https://github.com/airchains-network/evm-station.git
git clone https://github.com/airchains-network/tracks.git

2- Install Evmos (EVM Station)

# Go to directory
cd evm-station

# Install
go mod tidy
/bin/bash ./scripts/local-setup.sh

Config Evmos systemD

# Create env file
nano ~/.rollup-env

Copy and Paste below codes in the env file (Don't Change anything)

MONIKER="localtestnet"
KEYRING="test"
KEYALGO="eth_secp256k1"
LOGLEVEL="info"
HOMEDIR="$HOME/.evmosd"
TRACE=""
BASEFEE=1000000000
CONFIG=$HOMEDIR/config/config.toml
APP_TOML=$HOMEDIR/config/app.toml
GENESIS=$HOMEDIR/config/genesis.json
TMP_GENESIS=$HOMEDIR/config/tmp_genesis.json
VAL_KEY="mykey"

Now let's start Evmos with systemD

Copy Paste the entire code below in the terminal

We use root user of vps but if you use wsl or a custom user you must change user by replacing root in the code

sudo tee /etc/systemd/system/rolld.service > /dev/null << EOF
[Unit]
Description=ZK
After=network.target

[Service]
User=root
EnvironmentFile=/root/.rollup-env
ExecStart=/root/evm-station/build/station-evm start --metrics "" --log_level info --json-rpc.api eth,txpool,personal,net,debug,web3 --chain-id "stationevm_1234-1"
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
EOF

Start Evmos

sudo systemctl daemon-reload
sudo systemctl enable rolld
sudo systemctl start rolld
sudo journalctl -u rolld -f --no-hostname -o cat

You should see the logs like below now, To exit: CTRL + C image

Get Private-key of Evmos (EVM Station)

Save the private key!

/bin/bash ./scripts/local-keys.sh

Change Ports

No need to change anything in the commands, as I am just teaching you what's happening with the commands

  • we set the variable G_PORT to a favorite number like 17 with these commands
echo "export G_PORT="17"" >> $HOME/.bash_profile
source $HOME/.bash_profile
  • We replace 17 with the first of the ports in app.toml with this command
sed -i.bak -e "s%:1317%:${G_PORT}317%g;
s%:8080%:${G_PORT}080%g;
s%:9090%:${G_PORT}090%g;
s%:9091%:${G_PORT}091%g;
s%:8545%:${G_PORT}545%g;
s%:8546%:${G_PORT}546%g;
s%:6065%:${G_PORT}065%g" $HOME/.evmosd/config/app.toml
  • We replace 17 with the first of the ports in config.toml with this command
sed -i.bak -e "s%:26658%:${G_PORT}658%g;
s%:26657%:${G_PORT}657%g;
s%:6060%:${G_PORT}060%g;
s%:26656%:${G_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${G_PORT}656\"%;
s%:26660%:${G_PORT}660%g" $HOME/.evmosd/config/config.toml
sed -i -e 's/address = "127.0.0.1:17545"/address = "0.0.0.0:17545"/' -e 's/ws-address = "127.0.0.1:17546"/address = "0.0.0.0:17546"/' $HOME/.evmosd/config/app.toml
sudo ufw allow 17545
sudo ufw allow 17546
  • Restart Evmos systemD
sudo systemctl restart rolld
  • Check logs if you want
sudo journalctl -u rolld -f --no-hostname -o cat

3- Install Avail DA

We will use Avail Turing as the DA layer. We have other options like Celestia, EigenLayer or MockDA but we choose Avail, Remember, You CANNOT change DA later

cd $HOME
git clone https://github.com/availproject/availup.git
cd availup
/bin/bash availup.sh --network "turing" --app_id 36

image

  • Close it with Ctrl+C

Config systemD for Avail DA

Copy Paste All the code below in the terminal and Enter!

sudo tee /etc/systemd/system/availd.service > /dev/null <<'EOF'
[Unit]
Description=Avail Light Node
After=network.target
StartLimitIntervalSec=0

[Service]
User=root
Type=simple
Restart=always
RestartSec=120
ExecStart=/root/.avail/turing/bin/avail-light --network turing --app-id 36 --identity /root/.avail/identity/identity.toml

[Install]
WantedBy=multi-user.target
EOF

We use root user of vps but if you use wsl or a custom user you must change user by replacing root in the code

Start Avail DA systemD

systemctl daemon-reload 
sudo systemctl enable availd
sudo systemctl start availd
sudo journalctl -u availd -f --no-hostname -o cat

image Exit: Ctrl+C

Save Avail DA Seed Phrase (Mnemonic)

cat ~/.avail/identity/identity.toml

Get Faucet

Import your Avail DA Mnemonic to the Subwallet to create a polkadot wallet

Get your address in subwallet and get Avail faucet with $faucet in the discord Screenshot_43

You can also get Avail faucet here (Turing)

4- Install Tracks

Go to tracks directory

cd $HOME
cd tracks
go mod tidy

Initiate Tracks

  • Replace Avail-Wallet-Address with your Avail DA wallet
  • Replace moniker-name with your favorite name
  • I have choosen 17 in Change Ports step so I put 17 for the ports here, if you didn't change then you are okay
go run cmd/main.go init --daRpc "http://127.0.0.1:7000" --daKey "Avail-Wallet-Address" --daType "avail" --moniker "moniker-name" --stationRpc "http://127.0.0.1:17545" --stationAPI "http://127.0.0.1:17545" --stationType "evm"

image

Create Tracks Address

  • Replace moniker-name
go run cmd/main.go keys junction --accountName moniker-name --accountPath $HOME/.tracks/junction-accounts/keys

Save the output of this command (Mnemonic & Address)

Use wallet address with perfix air and get faucet with $faucet in switchyard-faucet in the discord Screenshot_44

Run Prover

go run cmd/main.go prover v1EVM

image

Find node_id

  • Find node_id with this command and save it
cat ~/.tracks/config/sequencer.toml

Screenshot_45

Create Station

  • Replace moniker-name
  • Replace WALLET_ADDRESS with air... wallet you saved before
  • Replace IP with your VPS server IP
  • Replace node_id with your node id you saved
go run cmd/main.go create-station --accountName moniker-name --accountPath $HOME/.tracks/junction-accounts/keys --jsonRPC "https://airchains-testnet-rpc.cosmonautstakes.com/" --info "EVM Track" --tracks WALLET_ADDRESS --bootstrapNode "/ip4/IP/tcp/2300/p2p/node_id"

Screenshot_46

Create Station systemD file

sudo tee /etc/systemd/system/stationd.service > /dev/null << EOF
[Unit]
Description=station track service
After=network-online.target
[Service]
User=root
WorkingDirectory=/root/tracks/
ExecStart=/usr/local/go/bin/go run cmd/main.go start
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

Run Station Node with systemD

sudo systemctl daemon-reload
sudo systemctl enable stationd
sudo systemctl restart stationd
sudo journalctl -u stationd -f --no-hostname -o cat

Screenshot_47 Exit: Ctrl+C

Check Pod Tracker Logs

sudo journalctl -u stationd -f --no-hostname -o cat

Installation is Complete but How to earn Points?

image

  • You have completed the installation process. You can import your tracker air... wallet mnemonic to Leap Wallet and connect https://points.airchains.io/ to check your points

  • Yes, You have 0 Points now. The reason for this is that you need to extract a pod to earn points

  • Each pod is 25 transactions. Each set of 25 transactions will generate 1 pod, and you will earn 5 points from these transactions

  • The initial 100 points from the installation will become active after the 1st pod too

  • You have to make transactions with your evmos station privatekey created with command bin/bash ./scripts/local-keys.sh in this step

  • Import your private key in Metamask and "Add Network" like this(Replace IP with your server IP):

rpc: http://IP:17545

chain id: 1234

ticker: FITFI
  • Now you can either deploy a contract with Remix or manually send transactions like trasnfer funds

  • You can should track your pods creation after each 25 transactions with this command

sudo journalctl -u stationd -f --no-hostname -o cat

Screenshot_48

As you see, I verified 3 pods which means I did 75 (3x25) transactions

  • If you ever experiencing RPC error during the station tracking logs, you have to roll back 1 to 3 times to solve it
sudo systemctl stop stationd
cd tracks
git pull
go run cmd/main.go rollback
sudo systemctl restart stationd
sudo journalctl -u stationd -f --no-hostname -o cat

You can repeat go run cmd/main.go rollback command 3 times

Auto tx script

What if we don't want to f..k with metamask and rest in bed by jsut running a script to transact automatically ??

Remember, You have to check your RPC health with Metamask "Add Network" before going through this step

Install Dependecies

sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip screen -y
sudo apt install -y curl git jq lz4 build-essential cmake perl automake autoconf libtool wget libssl-dev -y
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt install nodejs npm 
npm install -g npm@10.8.1
npm install web3@1.5.3

Config Script

nano corenodetx.js
  • Copy & Paste the entire code below in the file
  • No need to change anything
const readline = require('readline');
const Web3 = require('web3');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question('Enter your private key: ', (privateKey) => {
  rl.question('Enter recipients address: ', (toAddress) => {
    rl.question('Enter amount of tokens you want to transfer: ', (amount) => {
      rl.question('How many seconds do you want to repeat the proccss? if you enter 30 then it transacts per 30 seconds: ', (interval) => {

        const rpcURL = "http://localhost:17545"; // or your server IP: "http://your-server-ip:17545"
        const web3 = new Web3(new Web3.providers.HttpProvider(rpcURL));

        function sendTransaction() {
          const account = web3.eth.accounts.privateKeyToAccount(privateKey);
          web3.eth.accounts.wallet.add(account);
          web3.eth.defaultAccount = account.address;

          const tx = {
            from: web3.eth.defaultAccount,
            to: toAddress,
            value: web3.utils.toWei(amount, 'ether'),
            gas: 21000,
            gasPrice: web3.utils.toWei('1', 'gwei')
          };

          web3.eth.sendTransaction(tx)
            .then(receipt => {
              console.log('Transaction successful with hash:', receipt.transactionHash);
            })
            .catch(err => {
              console.error('Error sending transaction:', err);
            });
        }

        setInterval(sendTransaction, interval * 1000);

        rl.close();
      });
    });
  });
});

Ctrl + X Y Enter

Run Script

# Open screen
screen -S tx

# Run script
node corenodetx.js
  • Enter Private-key of your Evmos Station

  • Enter Receipt Address

  • Enter the Amount of the tokens you want to send

  • Enter the delay between txs in seconds - better you don't put less than 30 to be a normal user ;)

    image

Good Luck Have Fun with the testnet and follow Moei