Skip to main content

Initia

Installation

tip

You should update the MONIKER, WALLET, and PORT variables in the Setting up environment variables section. Make sure the port you specify is not already in use.

Check for ports already in use by visually inspecting the output of the lsof -i -P -n | grep LISTEN command. Almost all Cosmos chain nodes use ports xx317, xx656, xx657, and xx090. Therefore, avoid using ports starting with xx if they are already occupied.

Update OS

sudo apt update && sudo apt upgrade -y

Installation of required packages

sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip jq -y

Installation of go (if you need)

cd ~
VER="1.22.2" # Make sure that this version does not broke any other apps you run!
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

Setting up environment variables

echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="NGSolutionsWASHERE"" >> $HOME/.bash_profile
echo "export INITIA_CHAIN_ID="initiation-1"" >> $HOME/.bash_profile
echo "export INITIA_PORT="15"" >> $HOME/.bash_profile
source $HOME/.bash_profile

Downloading and installing node

## Following line deletes all the files under the ~/initiaprotocol directory.
## Please make sure that you have backed up everything you need
cd $HOME
rm -rf initia
git clone https://github.com/initia-labs/initia.git
cd initia
git checkout v0.2.15
make install

Initializing the node

initiad init $MONIKER
initiad config set client chain-id $INITIA_CHAIN_
initiad config set client node tcp://localhost:${INITIA_PORT}657
sed -i -e "s|^node *=.*|node = \"tcp://localhost:${INITIA_PORT}657\"|" $HOME/.initia/config/client.toml

Downloading genesis and addressbook

cd $HOME
curl https://initia.rpc.ngsolutions.xyz/genesis? | jq ".result.genesis" > .initia/config/genesis.json
wget -O $HOME/.initia/config/addrbook.json https://snapshots.ngsolutions.xyz/addrbook/initia/addrbook.json

Setting seeds and peers

PEERS="d587b5f85da747e0e67fd3860662d65c8ba7599e@d587b5f85da747e0e67fd3860662d65c8ba7599e:15656,2692225700832eb9b46c7b3fc6e4dea2ec044a78@2692225700832eb9b46c7b3fc6e4dea2ec044a78:26656,44098b8e06c18c7ed4251c900fe51f4eb1205bf1@44098b8e06c18c7ed4251c900fe51f4eb1205bf1:51656,7d1b836677a9039cc76b6023f852ef3400b68043@7d1b836677a9039cc76b6023f852ef3400b68043:26656,329227cf8632240914511faa9b43050a34aa863e@329227cf8632240914511faa9b43050a34aa863e:26656,42cd9d7a33f8250ad2dbe04634e7c7c23fca6657@42cd9d7a33f8250ad2dbe04634e7c7c23fca6657:26656,46a1f4d489210b0d2da8280be787ac286c69320a@46a1f4d489210b0d2da8280be787ac286c69320a:38656"
sed -i -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.initia/config/config.toml

Setting custom ports

Updating ports in app.toml

sed -i.bak -e "s%:1317%:${INITIA_PORT}317%g;
s%:8080%:${INITIA_PORT}080%g;
s%:9090%:${INITIA_PORT}090%g;
s%:9091%:${INITIA_PORT}091%g;
s%:8545%:${INITIA_PORT}545%g;
s%:8546%:${INITIA_PORT}546%g;
s%:6065%:${INITIA_PORT}065%g" $HOME/.initia/config/app.toml

Updating ports in config.toml

sed -i.bak -e "s%:26658%:${INITIA_PORT}658%g;
s%:26657%:${INITIA_PORT}657%g;
s%:6060%:${INITIA_PORT}060%g;
s%:26656%:${INITIA_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${INITIA_PORT}656\"%;
s%:26660%:${INITIA_PORT}660%g" $HOME/.initia/config/config.toml

Configuring pruning settings

sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.initia/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.initia/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"10\"/" $HOME/.initia/config/app.toml
# Followgin command disables indexing, if you dont know what it means, just disable. However, if you need to hos an explorer, you might need it.
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.initia/config/config.toml

Setting gas and other configurations

sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.0025uinit"|g' $HOME/.initia/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.initia/config/config.toml
sed -i 's/max_num_inbound_peers =.*/max_num_inbound_peers = 50/g' $HOME/.initia/config/config.toml
sed -i 's/max_num_outbound_peers =.*/max_num_outbound_peers = 50/g' $HOME/.initia/config/config.to

Creating service file

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

Snapshot

danger

Important: Back Up Your Validator Key

Before resetting your node, ensure you have a backup of your priv_validator_key.json file. This is especially important if you've already created a validator. Without a backup, resetting the node will result in lost access and require you to create a new validator from scratch.

info

This script creates a copy of your priv_validator_state.json and priv_validator_key.json files. It then copies the original private files back after downloading the snapshot. However, use this script with caution to avoid any potential failures.

  1. Create Backups of Private Files.

    cp $HOME/.initia/data/priv_validator_state.json $HOME/priv_validator_state.json.initia.backup
    cp $HOME/.initia/config/priv_validator_key.json $HOME/priv_validator_key.json.initia.backup
  2. Reset Node and Download Snapshot

    # initiad tendermint unsafe-reset-all --home $HOME/.initia --keep-addr-book
    # curl https://snapshots.ngsolutions.xyz/snapshots/initia/snap_initia.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.initia
  3. Restore Backed Up Files

    cp $HOME/priv_validator_state.json.initia.backup $HOME/.initia/data/priv_validator_state.json
    cp $HOME/priv_validator_key.json.initia.backup $HOME/.initia/config/priv_validator_key.json

Enabling and starting the service.

# You need to inspect logs visually after the  to make sure that it is working
sudo systemctl daemon-reload
sudo systemctl enable initiad
sudo systemctl restart initiad && sudo journalctl -u initiad -f

Creating a wallet

You need to create or import a wallet to request test tokens. If you dont have any tokens, you will not be able to create a validator.

# Following command creates a new wallet.
# Copy mnemonics to a safe place
# If you lost your mnemonics you will not be able to recover this wallet.
initiad keys add $WALLET

# If you want to import a wallet using mnemonics, execute following command and enter your mnemonics
initiad keys add $WALLET --recover

# Get your keys and their addresses to request faucet
initiad keys list

Creating a validator

Before you begin:

It's crucial to ensure your node is synchronized with the network before attempting to create a validator. This ensures your validator operates with the latest blockchain data.

Checking Synchronization Status:

Use the following snippet to check your node's synchronization status. If the snippet returns false, your node is in sync and ready to proceed. However, if it returns true, your node is still catching up. In that case, please wait until the synchronization completes before creating a validator.

initiad status | jq -r .sync_info.catching_up

Creating a Validator:

The following snippet will create a validator.json file in your node's home directory. This file stores the details necessary to create your validator. While you can edit the validator.json file later, keep in mind that doing so may incur token fees. Therefore, it's important to ensure the information within the file is accurate before proceeding.

cd $HOME
# Create validator.json file
echo "{
\"pubkey\":{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"$(initiad comet show-validator | grep -Po '\"key\":\s*\"\K[^"]*')\"},
\"amount\": \"1000000uinit\",
\"moniker\": \"NGSolutionsWasHere\",
\"identity\": \"\",
\"website\": \"\",
\"security\": \"\",
\"details\": \"All heil NGSolutions\",
\"commission-rate\": \"0.1\",
\"commission-max-rate\": \"0.2\",
\"commission-max-change-rate\": \"0.01\",
\"min-self-delegation\": \"1\"
}" > .initia/validator.json

Next Steps:

Once you're satisfied with the contents of validator.json, you can proceed with creating the validator using the information stored within the file.

# Create a validator using the JSON configuration
initiad tx mstaking create-validator validator.json \
--from $WALLET \
--chain-id $INITIA_CHAIN_ID \
--fees 500uinit

Delegate to yourself

You might need to update number of tokens before executing the following command.

initiad tx staking delegate \
$(initiad keys show $WALLET --bech val -a) 2000000uinit \
--from $WALLET \
--chain-id $INITIA_CHAIN_ID \
--fees=500uinit

Deleting the node completely (if you need)

danger

Make sure that you backed up any required files to setup later! Do not lost your validator or wallet!

sudo systemctl stop initiad
sudo systemctl disable initiad
sudo rm -rf /etc/systemd/system/initiad.service
sudo rm $(which initiad)
sudo rm -rf $HOME/.initia
sed -i "/INITIA_/d" $HOME/.bash_profile