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

# Installation

## [**EXPLORER**](https://testnet.block-pro.net/0G/staking)

## **Hardware Requirements:**

| Node Type | CPU | RAM  | Storage |
| --------- | --- | ---- | ------- |
| Testnet   | 8   | 16GB | 250GB   |

## Preparing the server

```
sudo apt update && sudo apt upgrade -y
sudo apt install curl tar wget clang pkg-config libssl-dev jq build-essential bsdmainutils git make ncdu gcc git jq chrony liblz4-tool -y
```

## GO 1.21.6

```
ver="1.21.6"
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
```

## Build

```
cd $HOME && mkdir -p go/bin/
```

```
cd $HOME
rm -rf 0g-chain
wget -O 0gchaind https://github.com/0glabs/0g-chain/releases/download/v0.4.0/0gchaind-linux-v0.4.0
chmod +x $HOME/0gchaind
sudo mv $HOME/0gchaind $HOME/go/bin

0gchaind version --long | grep -e version -e commit
```

* version: 0.4.0
* commit: 840deea660500f3948300ea3e9a1cba878ed682b

<pre><code>0gchaind init <a data-footnote-ref href="#user-content-fn-1">BlockPro </a>--chain-id=zgtendermint_16600-2
0gchaind config --chain-id=zgtendermint_16600-2
</code></pre>

## Create/recover wallet

```
0gchaind keys add <walletname>
0gchaind keys add <walletname> --recover
```

## Download Genesis and addrbook

```
wget -O $HOME/.0gchain/config/genesis.json https://testnet-files.itrocket.net/og/genesis.json
wget -O $HOME/.0gchain/config/addrbook.json https://testnet-files.itrocket.net/og/addrbook.json
```

## Setup the minimum gas price and Peers

```
sed -i.bak -e "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0.025ua0gi\"/;" ~/.0gchain/config/app.toml
external_address=$(wget -qO- eth0.me) 
sed -i.bak -e "s/^external_address *=.*/external_address = \"$external_address:26656\"/" $HOME/.0gchain/config/config.toml
peers=""
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $HOME/.0gchain/config/config.toml
seeds=""
sed -i.bak -e "s/^seeds =.*/seeds = \"$seeds\"/" $HOME/.0gchain/config/config.toml
sed -i 's/max_num_inbound_peers =.*/max_num_inbound_peers = 50/g' $HOME/.0gchain/config/config.toml
sed -i 's/max_num_outbound_peers =.*/max_num_outbound_peers = 50/g' $HOME/.0gchain/config/config.toml
```

## Pruning

```
pruning="custom"
pruning_keep_recent="1000"
pruning_keep_every="0"
pruning_interval="10"
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.0gchain/config/app.toml
```

## Create a service file

```
sudo tee /etc/systemd/system/0gchaind.service > /dev/null <<EOF
[Unit]
Description=0gchaind
After=network-online.target

[Service]
User=$USER
ExecStart=$(which 0gchaind) start
Restart=on-failure
RestartSec=3
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOF
```

## Start

```
sudo systemctl daemon-reload
sudo systemctl enable 0gchaind  
sudo systemctl restart 0gchaind  && sudo journalctl -fu 0gchaind  -o cat
```

## Create validator

```
0gchaind tx staking create-validator \
  --amount 1000000ua0gi \
  --from <walletName> \
  --commission-max-change-rate "0.1" \
  --commission-max-rate "0.1" \
  --commission-rate "0.05" \
  --min-self-delegation "1" \
  --pubkey $(0gchaind tendermint show-validator) \
  --moniker YOUR_MONIKER_NAME \
  --chain-id zgtendermint_16600-2 \
  --identity="YOUR_KEYBASE_ID" \
  --details="YOUR_DETAILS" \
  --website="YOUR_WEBSITE_URL"
  --gas=500000 \
  --gas-prices=99999ua0gi \
  -y
```

## Delete node

```
sudo systemctl stop 0gchaind
sudo systemctl disable 0gchaind
rm /etc/systemd/system/0gchaind.service
sudo systemctl daemon-reload
cd $HOME
rm -rf 0g-chain
rm -rf .0gchain
rm -rf $(which 0gchaind)
```

[^1]: \[custom\_moniker]
