# 🔌  Installation

## Republic Node Installation Guide (Custom Setup)

### 1. Install Required Dependencies

First, update your system and install the necessary packages.

```
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 chrony liblz4-tool -y
```

## 2. Install Go

This setup uses **Go v1.22.5**.\
If Go is already installed on your server, you may skip this step.

```
GO_VERSION="1.22.5"

wget "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
rm "go${GO_VERSION}.linux-amd64.tar.gz"

echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bash_profile
source ~/.bash_profile

go version
```

***

## 3. Install Republic Binary

Download the node binary and move it to your Go binary directory.

```
wget https://github.com/RepublicAI/networks/releases/download/v0.1.0/republicd-linux-amd64 -O republicd
chmod +x republicd
mv republicd $HOME/go/bin/
```

Verify the installation:

```
republicd version --long | grep -e version -e commit
```

***

## 4. Initialize the Node

Replace `<MONIKER>` with your preferred node name.

```
republicd init <MONIKER> --chain-id raitestnet_77701-1
```

***

## 5. Download Genesis and Addrbook

### Genesis File

```
curl -L https://snapshot.vinjan-inc.com/republic/genesis.json > $HOME/.republic/config/genesis.json
```

### Addrbook File

```
curl -L https://snapshot.vinjan-inc.com/republic/addrbook.json > $HOME/.republic/config/addrbook.json
```

***

## 6. Custom Port Configuration

To avoid conflicts with other nodes, configure custom ports.

```
CUSTOM_PORT=211
```

```
sed -i -e "s%:26657%:${CUSTOM_PORT}57%" $HOME/.republic/config/client.toml

sed -i -e "s%:26658%:${CUSTOM_PORT}58%; \
s%:26657%:${CUSTOM_PORT}57%; \
s%:6060%:${CUSTOM_PORT}60%; \
s%:26656%:${CUSTOM_PORT}56%; \
s%:26660%:${CUSTOM_PORT}61%" $HOME/.republic/config/config.toml

sed -i -e "s%:1317%:${CUSTOM_PORT}17%; \
s%:9090%:${CUSTOM_PORT}90%; \
s%:8545%:${CUSTOM_PORT}45%; \
s%:8546%:${CUSTOM_PORT}46%; \
s%:6065%:${CUSTOM_PORT}65%" $HOME/.republic/config/app.toml
```

***

## 7. Configure Peers and Gas Settings

Set the persistent peers to connect to the network faster.

```
PEERS="6313f892ee50ca0b2d6cc6411ac5207dbf2d164b@peers-t.republic.vinjan-inc.com:13356,7fef6e3bb5c254c777449e09e9cf0ee40f4cdee3@195.201.160.23:13356,1fc361b76cb5d3190027e18299a22e3dcb689dd9@54.159.96.158:26656"

sed -i -e "s|^persistent_peers *=.*|persistent_peers = \"$PEERS\"|" $HOME/.republic/config/config.toml
```

Set minimum gas price:

```
sed -i -e "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"2500000000arai\"/" $HOME/.republic/config/app.toml
```

***

## 8. Configure Pruning (Disk Optimization)

Enable pruning to reduce disk usage.

```
sed -i \
-e 's|^pruning *=.*|pruning = "custom"|' \
-e 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|' \
-e 's|^pruning-keep-every *=.*|pruning-keep-every = "0"|' \
-e 's|^pruning-interval *=.*|pruning-interval = "20"|' \
$HOME/.republic/config/app.toml
```

***

## 9. Disable Indexer

Disabling the indexer helps reduce disk usage and improves performance.

```
sed -i 's|^indexer *=.*|indexer = "null"|' $HOME/.republic/config/config.toml
```

***

## 10. Create System Service

Create a **systemd service** so the node runs automatically in the background.

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

[Service]
User=$USER
ExecStart=$(which republicd) start
Restart=always
RestartSec=5
LimitNOFILE=65535

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

***

## 11. Start the Node

Reload system services and start the node.

```
sudo systemctl daemon-reload
sudo systemctl enable republicd
sudo systemctl restart republicd
```

View logs:

```
sudo journalctl -u republicd -f -o cat
```
