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 FIAMMA_CHAIN_ID="fiamma-testnet-1"" >> $HOME/.bash_profile
echo "export FIAMMA_PORT="50"" >> $HOME/.bash_profile
source $HOME/.bash_profile
git clone https://github.com/fiamma-chain/fiamma.git
fiammad init $MONIKER --chain-id $FIAMMA_CHAIN_ID
sed -i -e "s|^node *=.*|node = \"tcp://localhost:${FIAMMA_PORT}657\"|" $HOME/.fiamma/config/client.toml
sed -i -e "s|^keyring-backend *=.*|keyring-backend = \"os\"|" $HOME/.fiamma/config/client.toml
sed -i -e "s|^chain-id *=.*|chain-id = \"fiamma-testnet-1\"|" $HOME/.fiamma/config/client.toml
# download genesis and addrbook
wget -O $HOME/.fiamma/config/genesis.json https://server-5.itrocket.net/testnet/fiamma/genesis.json
wget -O $HOME/.fiamma/config/addrbook.json https://server-5.itrocket.net/testnet/fiamma/addrbook.json
SEEDS="1e8777199f1edb3a35937e653b0bb68422f3c931@fiamma-testnet-seed.itrocket.net:50656"
PEERS="16b7389e724cc440b2f8a2a0f6b4c495851934ff@fiamma-testnet-peer.itrocket.net:49656,db875e2cb29c22752486422244c006ab13734149@46.4.91.76:29556,4f5efac1afd504f3b16fa79199965dfbc45880e3@[2a03:cfc0:8000:13::b910:27be]:14356,1a0ff9e5c08df76b19556b50aff82ec6dfd5beee@65.109.53.24:45656,4d776c7de10b81f0d81ef8a056548b002d1eb801@87.120.165.181:26656,ccf2182de7b813cfbdf4560c54ee87962f0f5b65@188.40.85.207:14456,ddb0fd5cf50a7d9c816a08dfcaa14099f7cf2493@65.109.112.148:40056,36f33fb00260f16532a061b9926e352bb7cbf004@85.239.241.218:37656,a12e8531f345ccff39f47847aabf12e73e216ee3@144.76.97.251:26796,5e5f2eb750f8e1098f71b8287240fbaeb4e90f6e@152.53.110.139:32656"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" \
-e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.fiamma/config/config.toml
# set custom ports in app.toml
sed -i.bak -e "s%:1317%:${FIAMMA_PORT}317%g;
s%:8080%:${FIAMMA_PORT}080%g;
s%:9090%:${FIAMMA_PORT}090%g;
s%:9091%:${FIAMMA_PORT}091%g;
s%:8545%:${FIAMMA_PORT}545%g;
s%:8546%:${FIAMMA_PORT}546%g;
s%:6065%:${FIAMMA_PORT}065%g" $HOME/.fiamma/config/app.toml
# set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${FIAMMA_PORT}658%g;
s%:26657%:${FIAMMA_PORT}657%g;
s%:6060%:${FIAMMA_PORT}060%g;
s%:26656%:${FIAMMA_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${FIAMMA_PORT}656\"%;
s%:26660%:${FIAMMA_PORT}660%g" $HOME/.fiamma/config/config.toml
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.fiamma/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.fiamma/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"19\"/" $HOME/.fiamma/config/app.toml
# set minimum gas price, enable prometheus and disable indexing
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.00001ufia"|g' $HOME/.fiamma/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.fiamma/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.fiamma/config/config.toml
sudo tee /etc/systemd/system/fiammad.service > /dev/null <<EOF
After=network-online.target
WorkingDirectory=$HOME/.fiamma
ExecStart=$(which fiammad) start --home $HOME/.fiamma
WantedBy=multi-user.target
# reset and download snapshot
fiammad tendermint unsafe-reset-all --home $HOME/.fiamma
curl https://server-5.itrocket.net/testnet/fiamma/fiamma_2025-02-22_1555116_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.fiamma
# enable and start service
sudo systemctl daemon-reload
sudo systemctl enable fiammad
sudo systemctl restart fiammad && sudo journalctl -u fiammad -fo cat