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
echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="test"" >> $HOME/.bash_profile
echo "export INITIA_CHAIN_ID="initiation-2"" >> $HOME/.bash_profile
echo "export INITIA_PORT="51"" >> $HOME/.bash_profile
source $HOME/.bash_profile
git clone https://github.com/initia-labs/initia.git
initiad config set client chain-id initiation-2
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
# download genesis and addrbook
wget -O $HOME/.initia/config/genesis.json https://server-6.itrocket.net/testnet/initia/genesis.json
wget -O $HOME/.initia/config/addrbook.json https://server-6.itrocket.net/testnet/initia/addrbook.json
SEEDS="cd69bcb00a6ecc1ba2b4a3465de4d4dd3e0a3db1@initia-testnet-seed.itrocket.net:51656"
PEERS="67b58592de11a6885d71d3ea436dc284b816caa3@initia-testnet-peer.itrocket.net:51656,df102b3fad9b66042eb9193fcbe10a7c0648e25b@65.109.28.157:25756,3715cdb41efb45714eb534c3943c5947f4894787@34.143.179.242:26656,016489c0258f38fe68f71c0d657325568197ef5a@34.87.185.37:26656,a671a31831fabdc602e40d8d5a2c45cbf3992262@135.125.160.145:26656,8eaa6a0d98810570798e10d54cf1da75fe7c0abb@72.251.3.24:56116,242c701c4892196e36e994848575374f91ed7388@64.185.227.98:25756,dd68f170ee7e0177e207e848a422fb0f66d94237@162.55.242.213:15656,52841e86d840b2c460ed7b9687d368d9b5d40146@57.129.52.22:26656"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" \
-e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" \
$HOME/.initia/config/config.toml
# set custom 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
# set custom ports in config.toml file
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
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 = \"50\"/" $HOME/.initia/config/app.toml
# set minimum gas price, enable prometheus and disable indexing
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.015uinit"|g' $HOME/.initia/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.initia/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.initia/config/config.toml
sudo tee /etc/systemd/system/initiad.service > /dev/null <<EOF
After=network-online.target
WorkingDirectory=$HOME/.initia
ExecStart=$(which initiad) start --home $HOME/.initia
WantedBy=multi-user.target
# reset and download snapshot
initiad tendermint unsafe-reset-all --home $HOME/.initia
curl https://server-6.itrocket.net/testnet/initia/initia_2025-02-22_5750545_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.initia
# enable and start service
sudo systemctl daemon-reload
sudo systemctl enable initiad
sudo systemctl restart initiad && sudo journalctl -u initiad -f