This guide was partially excerpted from the guides by Nodebrand, JosephTran, and ValidatorVN.

  1. Install
sudo apt update
sudo apt install curl git jq build-essential gcc unzip wget lz4 -y
cd $HOME && \\
ver="1.23.3" && \\
wget "<https://golang.org/dl/go$ver.linux-amd64.tar.gz>" && \\
sudo rm -rf /usr/local/go && \\
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \\
rm "go$ver.linux-amd64.tar.gz" && \\
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile && \\
source $HOME/.bash_profile && \\
go version
# Update or add MONIKER
grep -q '^export MONIKER=' ~/.bash_profile && \\
  sed -i 's/export MONIKER="[^"]*"/export MONIKER="zstake"/' ~/.bash_profile || \\
  echo 'export MONIKER="zstake"' >> ~/.bash_profile

# Update or add CHAIN_ID
grep -q '^export CHAIN_ID=' ~/.bash_profile && \\
  sed -i 's/export CHAIN_ID="[^"]*"/export CHAIN_ID="zgtendermint_16600-2"/' ~/.bash_profile || \\
  echo 'export CHAIN_ID="zgtendermint_16600-2"' >> ~/.bash_profile

# Update or add WALLET_NAME
grep -q '^export WALLET_NAME=' ~/.bash_profile && \\
  sed -i 's/export WALLET_NAME="[^"]*"/export WALLET_NAME="wallet"/' ~/.bash_profile || \\
  echo 'export WALLET_NAME="wallet"' >> ~/.bash_profile

# Update or add RPC_PORT
grep -q '^export RPC_PORT=' ~/.bash_profile && \\
  sed -i 's/export RPC_PORT="[^"]*"/export RPC_PORT="26657"/' ~/.bash_profile || \\
  echo 'export RPC_PORT="26657"' >> ~/.bash_profile

# Update or add 0G_HOME
grep -q '^export OG_HOME=' ~/.bash_profile && \\
  sed -i 's/export OG_HOME="[^"]*"/export OG_HOME="$HOME/.0gchain"/' ~/.bash_profile || \\
  echo 'export OG_HOME="$HOME/.0gchain"' >> ~/.bash_profile
 
source ~/.bash_profile
  1. Git install
cd $HOME
rm -rf 0g-chain
git clone <https://github.com/0glabs/0g-chain.git>
cd 0g-chain
git checkout v0.3.1
git submodule update --init
make install
0gchaind version
  1. 0gchain Install
0gchaind config keyring-backend os
0gchaind config chain-id zgtendermint_16600-2
0gchaind init "zstake" --chain-id zgtendermint_16600-2
0gchaind config node tcp://localhost:26657
rm ~/.0gchain/config/genesis.json
wget -P ~/.0gchain/config <https://vps4.josephtran.xyz/0g/genesis.json>
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,8f21742ea5487da6e0697ba7d7b36961d3599567@og-testnet-seed.itrocket.net:47656"
PEERS="80fa309afab4a35323018ac70a40a446d3ae9caf@og-testnet-peer.itrocket.net:11656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:12656"
sed -i -e "/^\\[p2p\\]/,/^\\[/{s/^[[:space:]]*seeds *=.*/seeds = \\"$SEEDS\\"/}" \\
       -e "/^\\[p2p\\]/,/^\\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \\"$PEERS\\"/}" $HOME/.0gchain/config/config.toml
sed -i -e "s/^pruning *=.*/pruning = \\"custom\\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \\"100\\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \\"50\\"/" $HOME/.0gchain/config/app.toml
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.00025ua0gi"|g' $HOME/.0gchain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.0gchain/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \\"kv"/" $HOME/.0gchain/config/config.toml
sed -i 's|^\\s*#\\?\\s*laddr\\s*=\\s*"tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|' $HOME/.0gchain/config/config.toml
sed -i 's|^\\s*#\\?\\s*api\\s*=.*|api = "eth,txpool,personal,net,debug,web3"|' $HOME/.0gchain/config/app.toml
sed -i 's|^\\s*#\\?\\s*address\\s*=\\s*"127.0.0.1:8545"|address = "0.0.0.0:8545"|' $HOME/.0gchain/config/app.toml
sed -i 's|^\\s*#\\?\\s*ws-address\\s*=\\s*"127.0.0.1:8546"|ws-address = "0.0.0.0:8546"|' $HOME/.0gchain/config/app.toml
  1. 0gchain Service create
sudo tee /etc/systemd/system/0gd.service > /dev/null <<EOF
[Unit]
Description=0G Node
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=$(which 0gchaind) start --home $HOME/.0gchain
Restart=on-failure
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF