> For the complete documentation index, see [llms.txt](https://services.suntzu.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://services.suntzu.dev/testnet/0g.ai/installation.md).

# Installation

| Hardware | Minimum requirement |
| -------- | ------------------- |
| CPU      | 4                   |
| RAM      | 8+ GB               |
| Storage  | 1TB NVME  SSD       |

#### Install dependencies <a href="#install-dependencies" id="install-dependencies"></a>

```
sudo apt update
sudo apt-get install git curl build-essential make jq gcc snapd chrony lz4 tmux unzip bc -y
```

#### **INSTALL GO** <a href="#install-go" id="install-go"></a>

```
rm -rf $HOME/go
sudo rm -rf /usr/local/go
cd $HOME
curl https://dl.google.com/go/go1.20.5.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf -
cat <<'EOF' >>$HOME/.profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source $HOME/.profile
go version
```

#### Install Node <a href="#install-node" id="install-node"></a>

```
git clone -b v0.1.0 https://github.com/0glabs/0g-chain.git
./0g-chain/networks/testnet/install.sh
source .profile
```

#### **Set chain id** <a href="#initialize-node" id="initialize-node"></a>

```
0gchaind config chain-id zgtendermint_16600-1
```

#### **Initialize Node** <a href="#initialize-node" id="initialize-node"></a>

```
0gchaind init <your_validator_name> --chain-id zgtendermint_16600-1
```

#### Download genesis <a href="#download-genesis-and-addrbook" id="download-genesis-and-addrbook"></a>

```
wget -O $HOME/.0gchain/config/genesis.json https://github.com/0glabs/0g-chain/releases/download/v0.1.0/genesis.json

#Verify genesis
0gchaind validate-genesis

```

#### **Add seed and peer** <a href="#create-service" id="create-service"></a>

```
SEEDS=c4d619f6088cb0b24b4ab43a0510bf9251ab5d7f@54.241.167.190:26656,44d11d4ba92a01b520923f51632d2450984d5886@54.176.175.48:26656,f2693dd86766b5bf8fd6ab87e2e970d564d20aff@54.193.250.204:26656,f878d40c538c8c23653a5b70f615f8dccec6fb9f@18.166.164.232:26656
PEERS=
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.0gchain/config/config.toml
```

#### **Change port** <a href="#create-service" id="create-service"></a>

```
CUSTOM_PORT=115
sed -i.bak -e "s%:1317%:${CUSTOM_PORT}17%g;
s%:8080%:${CUSTOM_PORT}80%g;
s%:9090%:${CUSTOM_PORT}90%g;
s%:9091%:${CUSTOM_PORT}91%g;
s%:8545%:${CUSTOM_PORT}45%g;
s%:8546%:${CUSTOM_PORT}46%g;
s%:6065%:${CUSTOM_PORT}65%g" $HOME/.0gchain/config/app.toml

# set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${CUSTOM_PORT}58%g;
s%:26657%:${CUSTOM_PORT}57%g;
s%:6060%:${CUSTOM_PORT}60%g;
s%:26656%:${CUSTOM_PORT}56%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${CUSTOM_PORT}56\"%;
s%:26660%:${CUSTOM_PORT}60%g" $HOME/.0gchain/config/config.toml
```

#### **Config pruning** <a href="#create-service" id="create-service"></a>

```
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
```

#### **Create Service** <a href="#create-service" id="create-service"></a>

```
sudo tee /etc/systemd/system/0g-ai.service > /dev/null <<EOF
[Unit]
Description=0g Daemon
After=network-online.target
[Service]
User=$USER
ExecStart=$(which 0gchaind) start
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable 0g-ai
```

#### **Download Snapshot** <a href="#download-snapshot" id="download-snapshot"></a>

```
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book 
curl https://testnet-files.suntzu.dev/download/testnet/0g-ai/0g-ai-snapshot.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain
```

#### Start the node <a href="#start-the-node" id="start-the-node"></a>

```
sudo systemctl restart 0g-ai
journalctl -u 0g-ai -f
```
