# 🔌  Installation

**Install Go (if not already installed):**

```bash
cd $HOME
VERSION="1.23.1"
wget "https://golang.org/dl/go$VERSION.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go$VERSION.linux-amd64.tar.gz"
rm "go$VERSION.linux-amd64.tar.gz"
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile
source ~/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin
```

**Define Environment Variables:**

```bash
echo "export WALLET='wallet'" >> $HOME/.bash_profile
echo "export MONIKER='noderuner'" >> $HOME/.bash_profile
echo "export ZENROCK_CHAIN_ID='gardia-2'" >> $HOME/.bash_profile
echo "export ZENROCK_PORT=46657" >> $HOME/.bash_profile  # Set custom base port here
source ~/.bash_profile
```

**Download the Zenrockd Binary:**

```bash
cd $HOME
curl -o zenrockd https://releases.gardia.zenrocklabs.io/zenrockd-latest
chmod +x zenrockd
mv zenrockd ~/go/bin/
```

**Configure and Initialize Node:**

```bash
zenrockd init $MONIKER --chain-id $ZENROCK_CHAIN_ID
zenrockd config set client chain-id $ZENROCK_CHAIN_ID
zenrockd config set client node tcp://localhost:${ZENROCK_PORT}
```

**Download Genesis and Addrbook Files:**

```bash
wget -O $HOME/.zrchain/config/genesis.json https://raw.githubusercontent.com/mytolga/zenrock/refs/heads/main/genesis.json
wget -O $HOME/.zrchain/config/addrbook.json https://raw.githubusercontent.com/mytolga/zenrock/refs/heads/main/addrbook.json
```

**Set Seed and Peer Nodes:**

```bash
SEEDS="0ce55654cba1669707ebba8954413892ce8c0b31@zenrock-testnet-rpc.noderuner.xyz:46656"
PEERS=$(curl -sS https://zenrock-testnet-rpc.noderuner.xyz/net_info | jq -r '.result.peers[] | "\(.node_info.id)@\(.remote_ip):\(.node_info.listen_addr)"' | awk -F ':' '{print $1":"$(NF)}' | paste -sd, -)
echo $PEERS
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.zrchain/config/config.toml
```

**Update App Ports in `app.toml`:**

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

**Update Ports in `config.toml`:**

```bash
sed -i.bak -e "s%:26658%:${ZENROCK_PORT}58%g;
s%:26657%:${ZENROCK_PORT}57%g;
s%:6060%:${ZENROCK_PORT}60%g;
s%:26656%:${ZENROCK_PORT}56%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${ZENROCK_PORT}56\"%;
s%:26660%:${ZENROCK_PORT}60%g" $HOME/.zrchain/config/config.toml
```

**Set Pruning and Gas Prices:**

```bash
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.zrchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.zrchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $HOME/.zrchain/config/app.toml
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0urock"|g' $HOME/.zrchain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.zrchain/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.zrchain/config/config.toml
```

**Create Systemd Service File:**

```bash
sudo tee /etc/systemd/system/zenrockd.service > /dev/null <<EOF
[Unit]
Description=Zenrock Node Service
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.zrchain
ExecStart=$(which zenrockd) start --home $HOME/.zrchain
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
```

**Snapshot**&#x20;

```bash
Soon
```

**Enable and Start the Node:**

```bash
sudo systemctl daemon-reload
sudo systemctl enable zenrockd
sudo systemctl restart zenrockd && sudo journalctl -fu zenrockd -o cat
```


---

# Agent Instructions: 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://services.noderuner.xyz/zenrock/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.
