Docker

Using Docker

Running a node on one of Astar’s chains allows you to connect to the network, sync with our parachain and relay chain, obtain access to RPC endpoints, and much more.

Installation Instructions

A node can be spun up quickly using Docker. When connecting to Shiden on Kusama or Astar on Polkadot, it will take a few days to completely sync the relay chain. If you want to move faster you can use Kusama or Polkadot snapshots.
Create a local directory to store the chain data:
Astar
Shiden
Shibuya
1
mkdir /var/lib/astar/astar-db
Copied!
1
mkdir /var/lib/astar/shiden-db
Copied!
1
mkdir /var/lib/astar/shibuya-db
Copied!
Make sure you set the ownership and permissions accordingly. In this case, set the necessary permissions for a specific or current user (replace USER for the actual user that will run the docker command):
Astar
Shiden
Untitled
1
# chown to a specific user
2
chown USER /var/lib/astar/astar-db
3
4
# chown to current user
5
sudo chown -R $(id -u):$(id -g) /var/lib/astar/astar-db
Copied!
1
# chown to a specific user
2
chown USER /var/lib/astar/shiden-db
3
4
# chown to current user
5
sudo chown -R $(id -u):$(id -g) /var/lib/astar/shiden-db
Copied!
1
# chown to a specific user
2
chown USER /var/lib/astar/shibuya-db
3
4
# chown to current user
5
sudo chown -R $(id -u):$(id -g) /var/lib/astar/shibuya-db
Copied!

Prerequisites

  • Docker: Containerization platform for software solutions
  • Ngrok: Ngrok is a tunnel service to securely expose your RPC service in the local computer. auth-token is required for a dedicated connection.

Run a Full node

Replace NAME with your node name.
Astar
Shiden
Shibuya
1
# get container
2
sudo docker pull staketechnologies/astar-collator
3
4
# command to run full node - do not forget to change NAME to whatever you like
5
docker run -m 5G --name Shiden -p 30333:30333 \
6
-v "/var/lib/astar/shiden-db:/data" \
7
-u $(id -u ${USER}):$(id -g ${USER}) -d staketechnologies/astar-collator \
8
astar-collator --name NAME --chain astar --parachain-id 2006 --base-path /data --port 30333 --rpc-cors all --pruning archive \
9
--state-cache-size 1 --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0'
Copied!
1
# get container
2
sudo docker pull staketechnologies/astar-collator
3
4
# command to run full node - do not forget to change NAME to whatever you like
5
docker run -m 5G --name Shiden -p 30333:30333 \
6
-v "/var/lib/astar/shiden-db:/data" \
7
-u $(id -u ${USER}):$(id -g ${USER}) -d staketechnologies/astar-collator \
8
astar-collator --name NAME --base-path /data --port 30333 --rpc-cors all --pruning archive \
9
--state-cache-size 1 --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0'
Copied!
1
# get container
2
sudo docker pull staketechnologies/astar-collator
3
4
# command to run full node - do not forget to change NAME to whatever you like
5
docker run -m 5G --name Shiden -p 30333:30333 \
6
-v "/var/lib/astar/shibuya-db:/data" \
7
-u $(id -u ${USER}):$(id -g ${USER}) -d staketechnologies/astar-collator \
8
astar-collator --name NAME --chain shibuya --parachain-id 1000 --base-path /data --port 30333 --rpc-cors all --pruning archive \
9
--state-cache-size 1 --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0'
Copied!

Run an RPC node

One-line startup script

If one wants to finish the process without explanation, here is the one-line script for you. if you face an error upon execution, the descriptions below will help you to find where it needs to be adjusted. This script supposes that the running computer has docker and ngrokinstalled.
Shiden use only!
1
sudo curl -s https://raw.githubusercontent.com/AstarNetwork/Astar/rpc-script/scripts/rpc.sh > rpc.sh \
2
&& sudo bash ./rpc.sh \
3
-auth <your ngrok auth token>
Copied!

Running RPC node

Run this docker command first to spin up our full node and for integration partners to access the data. Start from running an archive node but add the flag
-l evm=debug,ethereum=debug,rpc=debug
Replace NAME with your node name.
Astar
Shiden
Shibuya
1
# get container
2
sudo docker pull staketechnologies/astar-collator
3
4
# command to run RPC node - do not forget to change **NAME** to whatever you like
5
docker run -m 5G --name Shiden -p 30334:30334 -p 30333:30333 -p 9933:9933 -p 9944:9944 \
6
-v "/var/lib/astar/shiden-db:/data" \\
7
-u $(id -u ${USER}):$(id -g ${USER}) -d --network=host staketechnologies/astar-collator \
8
astar-collator --name NAME --chain astar --parachain-id 2006 --base-path /data --port 30333 --rpc-port 9933 --rpc-cors=all --unsafe-rpc-external --unsafe-ws-external --pruning archive \
9
--state-cache-size 1 --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
10
-l evm=debug,ethereum=debug,rpc=debug \
Copied!
1
# get container
2
sudo docker pull staketechnologies/astar-collator
3
4
# command to run RPC node - do not forget to change **NAME** to whatever you like
5
docker run -m 5G --name Shiden -p 30334:30334 -p 30333:30333 -p 9933:9933 -p 9944:9944 \
6
-v "/var/lib/astar/shiden-db:/data" \
7
-u $(id -u ${USER}):$(id -g ${USER}) -d --network=host staketechnologies/astar-collator \
8
astar-collator --name NAME --base-path /data --port 30333 --rpc-port 9933 --rpc-cors=all --unsafe-rpc-external --unsafe-ws-external --pruning archive \
9
--state-cache-size 1 --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
10
-l evm=debug,ethereum=debug,rpc=debug \
Copied!
1
# get container
2
sudo docker pull staketechnologies/astar-collator
3
4
# command to run RPC node - do not forget to change **NAME** to whatever you like
5
docker run -m 5G --name Shiden -p 30334:30334 -p 30333:30333 -p 9933:9933 -p 9944:9944 \
6
-v "/var/lib/astar/shiden-db:/data" \
7
-u $(id -u ${USER}):$(id -g ${USER}) -d --network=host staketechnologies/astar-collator \
8
astar-collator --name NAME --chain shibuya --parachain-id 1000 --base-path /data --port 30333 --rpc-port 9933 --rpc-cors=all --unsafe-rpc-external --unsafe-ws-external --pruning archive \
9
--state-cache-size 1 --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
10
-l evm=debug,ethereum=debug,rpc=debug \
Copied!

Syncing to the latest block

If the RPC node is successfully running the node should be registered in telemetry. You will be able to see an RPC node syncing to the latest block with the NAME specified in the command.
Shiden Telemetry
During the syncing process, you will see messages from both the relay chain and the parachain in your logs. These messages display a target block (live network state) and the best block (local node synced state).
Make sure for the RPC node an HTTP connection is available.

Exposing to public

After checking the RPC node running locally, it can be connected to other clients that need access to the blockchain data such as The Graph node, Chainlink, and Blockscout. To expose an RPC node to the public requires a secure connection to the RPC. A tunnel is required for this. This can be achieved from [ngrok](<https://ngrok.com/>) . Run these commands to expose your web server port to the public. This will create a secure HTTPS connection without self-signed certificates.
1
snap install ngrok
2
/// after installation
3
ngrok http 9933
Copied!
After running the command, the terminal shows a screen like this.
Ngrok view
Ngrok default setting has an expiring session for 2 hours. To have persistent RPC exposure, sign up to their service, and set up auth token with the command:
1
ngrok authtoken <your ngrok auth token>
Copied!

Checking connections with ethers.js

If the node is running right, try this script to check if the connection is available.
1
const { ethers } = require("ethers");
2
3
const provider = new ethers.providers.JsonRpcProvider("https://<IP or domain name>");
4
5
async function checkBlocks() {
6
// Get block height of the network
7
const blocks = await provider.getBlockNumber();
8
console.log(blocks)
9
}
10
11
checkBlocks();
12
// prints current block height
Copied!
If the node is exposed, it should display the block height of the network.

Using Relaychain Snapshot

Running an Astar node can take days before it’s synced to the Kusama or Polkadot relay chain. You can speed up this process by using Polkashots:
Polkashots
This is the example for Shiden!
1
# navigate to ksmcc3
2
cd /var/lib/astar/shiden-db/polkadot/chains/ksmcc3
3
4
# if folder doesn't excist create and go navigate to the folder
5
sudo mkdir /var/lib/astar/shiden-db/polkadot/chains/ksmcc3 && cd /var/lib/astar/shiden-db/polkadot/chains/ksmcc3
6
7
# download the latest snapshot
8
wget <https://ksm-rocksdb.polkashots.io/snapshot> -O kusama.RocksDb.7z
9
10
# install 7z if not installed
11
sudo apt install p7zip-full
12
13
# extract snapshot (this can take some time)
14
7z x kusama.RocksDb.7z
15
16
# remove 7z file
17
rm -v kusama.RocksDb.7z
Copied!

How to update your node

As our development continues, it will sometimes be necessary to upgrade your node. Node operators will be notified in our Discord and Element group when upgrades are available and priority. The upgrade process is straightforward and is the same for all kinds of nodes.
  1. 1.
    Stop the docker container:
    sudo docker stop CONTAINER_ID
    If you don’t know the container_id, find it here sudo docker ps
  2. 2.
    Pull the latest version of Astar
  3. 3.
    Use the latest version to spin up your node.
Once your node is running again, you should see logs in your terminal.

Purge your node

If you need a fresh instance of your node, you can purge your node by removing the associated data directory.
You'll first need to stop the Docker container:
sudo docker stop CONTAINER_ID
Astar
Shiden
Shibuya
1
sudo rm -rf /var/lib/astar/aster-db/*
Copied!
1
sudo rm -rf /var/lib/astar/shiden-db/*
Copied!
1
sudo rm -rf /var/lib/astar/shibuya-db/*
Copied!
Last modified 13d ago