> For the complete documentation index, see [llms.txt](https://monkeylabs.gitbook.io/services/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://monkeylabs.gitbook.io/services/services-testnet/nillion/installation.md).

# Installation

| Chain ID                | Version | Custom Port |
| ----------------------- | ------- | ----------- |
| nillion-chain-testnet-1 | 0.2.2   | 55          |

Official Documentation Recommended Hardware: 16 Cores, 64GB RAM, 1000GB of storage (NVME)

### Manual Installation <a href="#installation" id="installation"></a>

```bash
# install dependencies, if needed
sudo apt update && sudo apt upgrade -y
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y
```

```bash
# install go, if needed
cd $HOME
VER="1.20.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"
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile
source $HOME/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin

# set vars
echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="test"" >> $HOME/.bash_profile
echo "export NILLION_CHAIN_ID="nillion-chain-testnet-1"" >> $HOME/.bash_profile
echo "export NILLION_PORT="55"" >> $HOME/.bash_profile
source $HOME/.bash_profile

# download binary
cd $HOME
rm -rf nilchain
git clone https://github.com/NillionNetwork/nilchain.git
cd nilchain
git checkout v0.2.1
make install
mv $HOME/nilchain $HOME/go/bin/

# config and init app
nilchaind config node tcp://localhost:${NILLION_PORT}657
nilchaind config keyring-backend os
nilchaind config chain-id nillion-chain-testnet-1
nilchaind init "test" --chain-id nillion-chain-testnet-1

# download genesis and addrbook
wget -O $HOME/.nilchain/config/genesis.json https://testnet-files.bonynode.online/nillion/genesis.json
wget -O $HOME/.nilchain/config/addrbook.json https://testnet-files.bonynode.online/nillion/addrbook.json

# set seeds and peers
SEEDS=
PEERS="0fb5ce425197a462a66de015ee5fbbf103835b8a@54.238.14.220:26656,7581c3fc378f1d6013e4f2eaa1e50fc3c25b9524@52.197.82.153:26656,d1a99acbf7139c9cf148357332986bbe7358793b@54.150.188.132:26656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.nilchain/config/config.toml

# set custom ports in app.toml
sed -i.bak -e "s%:1317%:${NILLION_PORT}317%g;
s%:8080%:${NILLION_PORT}080%g;
s%:9090%:${NILLION_PORT}090%g;
s%:9091%:${NILLION_PORT}091%g;
s%:8545%:${NILLION_PORT}545%g;
s%:8546%:${NILLION_PORT}546%g;
s%:6065%:${NILLION_PORT}065%g" $HOME/.nilchain/config/app.toml

# set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${NILLION_PORT}658%g;
s%:26657%:${NILLION_PORT}657%g;
s%:6060%:${NILLION_PORT}060%g;
s%:26656%:${NILLION_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${NILLION_PORT}656\"%;
s%:26660%:${NILLION_PORT}660%g" $HOME/.nilchain/config/config.toml

# config pruning
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.nilchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.nilchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $HOME/.nilchain/config/app.toml

# set minimum gas price, enable prometheus and disable indexing
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.01unil"|g' $HOME/.nilchain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.nilchain/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.nilchain/config/config.toml

# create service file
sudo tee /etc/systemd/system/nilchaind.service > /dev/null <<EOF
[Unit]
Description=Nillion node
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.nilchain
ExecStart=$(which nilchaind) start --home $HOME/.nilchain
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

# reset and download snapshot
nilchaind tendermint unsafe-reset-all --home $HOME/.nilchain
if curl -s --head curl https://testnet-files.bonynode.online/nillion/snap_nillion.tar.lz4 | head -n 1 | grep "200" > /dev/null; then
  curl https://testnet-files.bonynode.online/nillion/snap_nillion.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.nilchain
    else
  echo no have snap
fi

# enable and start service
sudo systemctl daemon-reload
sudo systemctl enable nilchaind
sudo systemctl restart nilchaind && sudo journalctl -u nilchaind -f
```

***Create Wallet***

```bash
# to create a new wallet, use the following command. don’t forget to save the mnemonic
nilchaind keys add $WALLET

# to restore exexuting wallet, use the following command
nilchaind keys add $WALLET --recover

# save wallet and validator address
WALLET_ADDRESS_nillion=$(nilchaind keys show $WALLET -a)
VALOPER_ADDRESS_nillion=$(nilchaind keys show $WALLET --bech val -a)
echo "export WALLET_ADDRESS_nillion="$WALLET_ADDRESS_nillion >> $HOME/.bash_profile
echo "export VALOPER_ADDRESS_nillion="$VALOPER_ADDRESS_nillion >> $HOME/.bash_profile
source $HOME/.bash_profile

# check sync status, once your node is fully synced, the output from above will print "false"
nilchaind status 2>&1 | jq 

# before creating a validator, you need to fund your wallet and check balance
nilchaind query bank balances $WALLET_ADDRESS_nillion 
```

***Create Validator***

```bash
nilchaind tx staking create-validator \
--amount 1000000unil \
--from $WALLET \
--commission-rate 0.1 \
--commission-max-rate 0.2 \
--commission-max-change-rate 0.01 \
--min-self-delegation 1 \
--pubkey $(nilchaind tendermint show-validator) \
--moniker "test" \
--identity "" \
--website "" \
--details "I love blockchain 💚" \
--chain-id nillion-chain-testnet-1 \
--gas auto --gas-adjustment 1.4 --gas-prices 0.01unil \
-y
```

#### Firewall security <a href="#firewall" id="firewall"></a>

Set the default to allow outgoing connections, deny all incoming, allow ssh and node p2p port

```bash
sudo systemctl stop nilchaind
sudo systemctl disable nilchaind
sudo rm -rf /etc/systemd/system/nilchaind.service
sudo rm $(which nilchaind)
sudo rm -rf $HOME/.nilchain
sed -i "/NILLION_/d" $HOME/.bash_profile
```

***Delete Node***

```bash
sudo systemctl stop nilchaind
sudo systemctl disable nilchaind
sudo rm -rf /etc/systemd/system/nilchaind.service
sudo rm $(which nilchaind)
sudo rm -rf $HOME/.nilchain
sed -i "/NILLION_/d" $HOME/.bash_profile
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://monkeylabs.gitbook.io/services/services-testnet/nillion/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
