Skip to content

Mantra

Installation

Terminal window
# 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
Terminal window
# install go, if needed
cd $HOME
VER="1.21.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 MANTRA_CHAIN_ID="mantra-dukong-1"" >> $HOME/.bash_profile
echo "export MANTRA_PORT="22"" >> $HOME/.bash_profile
source $HOME/.bash_profile
# download binary
cd $HOME
rm -rf $HOME/bin
mkdir $HOME/bin
cd $HOME/bin
wget https://github.com/MANTRA-Finance/public/releases/download/v3.0.0/mantrachaind-3.0.0-linux-amd64.tar.gz
tar -xvf mantrachaind-3.0.0-linux-amd64.tar.gz
rm mantrachaind-3.0.0-linux-amd64.tar.gz
chmod +x $HOME/bin/mantrachaind
sudo mv $HOME/bin/mantrachaind $HOME/go/bin
# config and init app
mantrachaind config node tcp://localhost:${MANTRA_PORT}657
mantrachaind config keyring-backend os
mantrachaind config chain-id mantra-dukong-1
mantrachaind init "test" --chain-id mantra-dukong-1
# download genesis and addrbook
wget -O $HOME/.mantrachain/config/genesis.json https://server-4.itrocket.net/testnet/mantra/genesis.json
wget -O $HOME/.mantrachain/config/addrbook.json https://server-4.itrocket.net/testnet/mantra/addrbook.json
# set seeds and peers
SEEDS="a9a71700397ce950a9396421877196ac19e7cde0@mantra-testnet-seed.itrocket.net:22656"
PEERS="1a46b1db53d1ff3dbec56ec93269f6a0d15faeb4@mantra-testnet-peer.itrocket.net:22656,e1b058e5cfa2b836ddaa496b10911da62dcf182e@134.65.192.193:36656,0b9d7d7daefacc1903cecef392c6f10528839fa6@34.92.64.233:26656,da54ab1be9e88bdfa2845269ef24f975bb1c90c1@34.130.170.97:26656,ae751ab62cffb7dda53a52e324d76cadf300ed9e@35.214.250.61:26656,e726816f42831689eab9378d5d577f1d06d25716@169.155.171.102:36656,593824b79d719e764832efca9e5137f29d1c49ca@88.218.226.175:26656,1f402acf2e4ad59aca187e84c64ef973b2b3c8bb@35.220.173.152:26656,d93d460d030779b93cb2cf874f64af37a263e4e0@34.96.191.10:26656,0bfc4c0e18f09c50f26a7ac38b1541c3024edb87@34.96.208.200:26656,7e061edecef73a700b699c785f61a44ca981ff7f@34.150.103.79:26656"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" \
-e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.mantrachain/config/config.toml
# set custom ports in app.toml
sed -i.bak -e "s%:1317%:${MANTRA_PORT}317%g;
s%:8080%:${MANTRA_PORT}080%g;
s%:9090%:${MANTRA_PORT}090%g;
s%:9091%:${MANTRA_PORT}091%g;
s%:8545%:${MANTRA_PORT}545%g;
s%:8546%:${MANTRA_PORT}546%g;
s%:6065%:${MANTRA_PORT}065%g" $HOME/.mantrachain/config/app.toml
# set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${MANTRA_PORT}658%g;
s%:26657%:${MANTRA_PORT}657%g;
s%:6060%:${MANTRA_PORT}060%g;
s%:26656%:${MANTRA_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${MANTRA_PORT}656\"%;
s%:26660%:${MANTRA_PORT}660%g" $HOME/.mantrachain/config/config.toml
# config pruning
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.mantrachain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.mantrachain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"19\"/" $HOME/.mantrachain/config/app.toml
# set minimum gas price, enable prometheus and disable indexing
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.0002uom"|g' $HOME/.mantrachain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.mantrachain/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.mantrachain/config/config.toml
# create service file
sudo tee /etc/systemd/system/mantrachaind.service > /dev/null <<EOF
[Unit]
Description=Mantra node
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.mantrachain
ExecStart=$(which mantrachaind) start --home $HOME/.mantrachain
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
# reset and download snapshot
mantrachaind tendermint unsafe-reset-all --home $HOME/.mantrachain
curl https://server-4.itrocket.net/testnet/mantra/mantra_2025-02-22_3402966_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.mantrachain
# enable and start service
sudo systemctl daemon-reload
sudo systemctl enable mantrachaind
sudo systemctl restart mantrachaind && sudo journalctl -u mantrachaind -fo cat

Create Wallet

Terminal window
# to create a new wallet, use the following command. don’t forget to save the mnemonic
mantrachaind keys add $WALLET
# to restore exexuting wallet, use the following command
mantrachaind keys add $WALLET --recover
# save wallet and validator address
WALLET_ADDRESS=$(mantrachaind keys show $WALLET -a)
VALOPER_ADDRESS=$(mantrachaind keys show $WALLET --bech val -a)
echo "export WALLET_ADDRESS="$WALLET_ADDRESS >> $HOME/.bash_profile
echo "export VALOPER_ADDRESS="$VALOPER_ADDRESS >> $HOME/.bash_profile
source $HOME/.bash_profile
# check sync status, once your node is fully synced, the output from above will print "false"
mantrachaind status 2>&1 | jq
# before creating a validator, you need to fund your wallet and check balance
mantrachaind query bank balances $WALLET_ADDRESS

Create Validator

Terminal window
cd $HOME
# Create validator.json file
echo "{\"pubkey\":{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"$(mantrachaind comet show-validator | grep -Po '\"key\":\s*\"\K[^"]*')\"},
\"amount\": \"1000000uom\",
\"moniker\": \"test\",
\"identity\": \"\",
\"website\": \"\",
\"security\": \"\",
\"details\": \"\",
\"commission-rate\": \"0.1\",
\"commission-max-rate\": \"0.2\",
\"commission-max-change-rate\": \"0.01\",
\"min-self-delegation\": \"1\"
}" > validator.json
# Create a validator using the JSON configuration
mantrachaind tx staking create-validator validator.json \
--from $WALLET \
--chain-id mantra-dukong-1 \
--gas auto --gas-adjustment 1.5 --fees 4000uom