0G Testnet Installation Guide
This guide provides step-by-step instructions for installing a 0G Testnet node on your system. Before you begin, ensure you have the necessary prerequisites.
Prerequisites
- Operating System: Linux (Ubuntu/Debian recommended) or macOS
- Go: Version 1.18 or higher
- Git: For cloning the repository
- Terminal: Access to a command-line interface
Hardware Requirement
Ensure your system meets the following hardware requirements to run the 0G Testnet node efficiently:
- CPU: 8 cores or more
- RAM: 64 GB or more
- Disk Space: 1000 GB SSD NVMe or more
- Network: Broadband internet connection with at least 100 Mbps upload/download speed
Installation
1. Setup prerequisites
sudo apt update -q
sudo apt install -y -qq make unzip clang pkg-config lz4 libssl-dev build-essential git jq ncdu bsdmainutils htop aria2 pvGO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
wget "https://dl.google.com/go/${GO_VERSION}.linux-amd64.tar.gz"
sudo tar -C /usr/local -xzf "${GO_VERSION}.linux-amd64.tar.gz"
rm "${GO_VERSION}.linux-amd64.tar.gz"
echo "export GOROOT=/usr/local/go" | tee -a ~/.profile
echo "export GOPATH=\$HOME/go" | tee -a ~/.profile
echo "export PATH=\$PATH:/usr/local/go/bin:\$HOME/go/bin" | tee -a ~/.profile
source ~/.profile2. Install 0G Binary
git clone https://github.com/0glabs/0g-chain.git
cd 0g-chain
git checkout v0.5.0
git submodule update --init
make install
0gchaind versionVerify the installation by checking the version
0gchaind version3. Configure the Node
Use 0gchaind init to set up your node for the Odyssey testnet. Replace 'Your Node Name' with a unique identifier.
CHAIN_ID='zgtendermint_16600-2'
MONIKER='Your Node Name'
DAEMON_HOME=$HOME/.0gchain
0gchaind config keyring-backend os
0gchaind config chain-id $OG_CHAIN_ID
0gchaind init $MONIKER --chain-id $OG_CHAIN_ID --home $DAEMON_HOME
0gchaind config node tcp://localhost:266574. Configure the Settings
DAEMON_HOME=$HOME/.0gchain
rm $DAEMON_HOME/config/genesis.json
wget -P $DAEMON_HOME/config https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $DAEMON_HOME/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $DAEMON_HOME/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $DAEMON_HOME/config/app.tomlChange custom port (optional)
DAEMON_HOME=$HOME/.0gchain
PORT_PREFIX=26
sed -i -e "
s%:1317%:${PORT_PREFIX}317%g;
s%:8080%:${PORT_PREFIX}080%g;
s%:9090%:${PORT_PREFIX}090%g;
s%:9091%:${PORT_PREFIX}091%g;
s%:8545%:${PORT_PREFIX}545%g;
s%:8546%:${PORT_PREFIX}546%g;
s%:6065%:${PORT_PREFIX}065%g
" $DAEMON_HOME/config/app.toml5. Install and Initialize Cosmovisor
Download the Cosmovisor binary using the go install command
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
cosmovisor versionInitialize Cosmovisor
DAEMON_NAME=0gd DAEMON_HOME=$HOME/.0gchain cosmovisor init $(which 0gchaind)6. Create Service
To ensure that the 0G Node processes run continuously and restart automatically on failure, you can create a systemd service. This will help manage the lifecycle of the processes and ensure they start on boot.
Create a new systemd service file :
sudo tee /etc/systemd/system/0gd.service >/dev/null <<EOF
[Unit]
Description=Cosmovisor 0G Chain
After=network-online.target
[Service]
User=$USER
Type=simple
WorkingDirectory=$HOME/.0gchain
ExecStart=$(which cosmovisor) run start --home $HOME/.0gchain
Restart=on-failure
RestartSec=3
LimitNOFILE=infinity
LimitNPROC=infinity
Environment="DAEMON_NAME=0gd"
Environment="DAEMON_HOME=$HOME/.0gchain"
Environment="UNSAFE_SKIP_BACKUP=true"
Environment="PATH=$PATH"
[Install]
WantedBy=multi-user.target
EOFNow apply the service configuration and start the services
sudo systemctl enable 0gd.service
sudo systemctl restart 0gd.serviceTo check the logs for the 0G Chain service, use the following command:
sudo journalctl -fu 0gd -o cat6. Applying Peers
To enhance network synchronization, we recommend applying our peers by following the steps below, or you can change the RPC URL to your own desired RPC URL:
PERSISTENT_PEERS=$(curl "https://scan.aldebaranode.xyz/api/scan/peers?rpc_url=https://rpc-a0gi-testnet.aldebaranode.xyz" | jq -r 'flatten | join(",")')
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PERSISTENT_PEERS\"/" $HOME/.0gchain/config/config.tomlsudo systemctl restart 0gd.service7. Applying Snapshot
To apply a snapshot for faster synchronization, follow the steps below:
Download snapshot
SNAP_NAME=light_0gchain_snapshot.lz4
SNAPSHOT_URL="https://josephtran.co/$SNAP_NAME"
(echo $SNAPSHOT_URL;) | aria2c -x 16 -s 16 -k 1M -i -Stop Service
sudo systemctl stop 0gdBackup Files
cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backupRemove Old Data
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-bookExtract Snapshot
lz4 -d -c $SNAP_NAME | pv | tar xv -C $HOME/.0gchain/ > /dev/nullRestore Files
cp $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.jsonStart Service
sudo systemctl start 0gd8. Setup Validator
Wallet Config
0gchaind keys add "WALLET" --ethGet Token
Get testnet tokens through faucet
- Official Faucet
- Discord Faucet
- Joseph Tran Community Faucet
Check Balance
0gchaind q bank balances $(0gchaind keys show "WALLET" -a)Create Validator
0gchaind tx staking create-validator \
--amount=1000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker="Your_node_name" \
--chain-id=zgtendermint_16600-2 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--details="Your validator description" \
--min-self-delegation="1" \
--from="WALLET" \
--gas=auto \
--gas-adjustment=1.4 \
--gas-prices 0.00252ua0gi \
-y