0G
Endpoints
API | RPC |
---|---|
https://0g.api.kgnodes.xyz | https://0g.rpc.kgnodes.xyz/ |
Explorer: https://explorer.kgnodes.xyz/og
Installation
Update OS
sudo apt update && sudo apt upgrade -y
Installing Dependencies
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y
Installing GO
ver="1.21.6"
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"
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile
source $HOME/.bash_profile
go version
Setting up environment variables
echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="yourmoniker"" >> $HOME/.bash_profile
echo "export OG_CHAIN_ID="zgtendermint_16600-2"" >> $HOME/.bash_profile
echo "export OG_PORT="42"" >> $HOME/.bash_profile
source $HOME/.bash_profile
Initializing and configuring the node
Download Binary
wget https://zgchaind-test.s3.ap-east-1.amazonaws.com/0gchaind-linux-v0.3.0
chmod +x ./0gchaind-linux-v0.3.0
mkdir -p /root/.0gchain/cosmovisor/upgrades/v0.3.0/bin
sudo cp -r ./0gchaind-linux-v0.3.0 /root/.0gchain/cosmovisor/upgrades/v0.3.0/bin/0gchaind
mkdir -p $HOME/.0gchain/cosmovisor/genesis/bin
mv /root/0gchaind-linux-v0.3.0 $HOME/.0gchain/cosmovisor/genesis/bin/0gchaind
wget https://github.com/0glabs/0g-chain/releases/download/v0.3.1.alpha.1/0gchaind-linux-v0.3.1.alpha.1
chmod +x ./0gchaind-linux-v0.3.1.alpha.1
mkdir -p /root/.0gchain/cosmovisor/upgrades/v0.3.1/bin
sudo mv ./0gchaind-linux-v0.3.1.alpha.1 /root/.0gchain/cosmovisor/upgrades/v0.3.1/bin/0gchaind
sudo ln -sfn $HOME/.0gchain/cosmovisor/genesis $HOME/.0gchain/cosmovisor/current
sudo ln -sfn $HOME/.0gchain/cosmovisor/current/bin/0gchaind /usr/local/bin/0gchaind
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.6.0
Node Settings
0gchaind config node tcp://localhost:${OG_PORT}657
0gchaind config keyring-backend file
0gchaind config chain-id zgtendermint_16600-2
Initializing the Node
0gchaind init "yourmoniker" --chain-id zgtendermint_16600-2
Downloading genesis and addressbook
wget -O $HOME/.0gchain/config/genesis.json https://snapshot.kgnodes.xyz/snapshot/0gchain/genesis.json
wget -O $HOME/.0gchain/config/addrbook.json https://snapshot.kgnodes.xyz/snapshot/0gchain/addrbook.json
Setting seeds and peers
SEEDS="8f21742ea5487da6e0697ba7d7b36961d3599567@og-testnet-seed.itrocket.net:47656"
PEERS="c0d35052a7612d992f721b25f186a5d1f569405e@195.201.194.188:26656,5c64398081c1330d94bc1c8ef8105054d00adb69@144.76.63.246:26656,0ae19691f97f5797694c253bc06c79c8b58ea2a8@85.190.242.81:26656,5e098c96e69e3e2a943b923eda791ba34543f792@116.202.210.96:26656,218c5a4efd14f30005dcb608507bccf1a5a16599@65.21.45.194:26656,a5fb2cb8fd9d8866de06193f4243a3ca55ecf41e@62.169.23.238:12656"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.0gchain/config/config.toml
Updating ports in app.toml
sed -i.bak -e "s%:1317%:${OG_PORT}317%g;
s%:8080%:${OG_PORT}080%g;
s%:9090%:${OG_PORT}090%g;
s%:9091%:${OG_PORT}091%g;
s%:8545%:${OG_PORT}545%g;
s%:8546%:${OG_PORT}546%g;
s%:6065%:${OG_PORT}065%g" $HOME/.0gchain/config/app.toml
Updating ports in config.toml
sed -i.bak -e "s%:26658%:${OG_PORT}658%g;
s%:26657%:${OG_PORT}657%g;
s%:6060%:${OG_PORT}060%g;
s%:26656%:${OG_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${OG_PORT}656\"%;
s%:26660%:${OG_PORT}660%g" $HOME/.0gchain/config/config.toml
Configuring pruning settings
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $HOME/.0gchain/config/app.toml
Setting gas and other configurations
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0ua0gi"|g' $HOME/.0gchain/config/app.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.0gchain/config/config.toml
Creating service file
sudo tee /etc/systemd/system/0gchaind.service > /dev/null <<EOF
[Unit]
Description=0gchaind node service
After=network-online.target
[Service]
User=$USER
ExecStart=$(which cosmovisor) run start --log_output_console
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
Environment="DAEMON_HOME=$HOME/.0gchain"
Environment="DAEMON_NAME=0gchaind"
Environment="UNSAFE_SKIP_BACKUP=true"
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:$HOME/.0gchain/cosmovisor/current/bin"
[Install]
WantedBy=multi-user.target
EOF
Enabling and starting the service
sudo systemctl daemon-reload
sudo systemctl enable 0gchaind
Downloading latest snap
Latest Snapshot:
Size | Heigt | Time | Indexer |
---|---|---|---|
5.0G | 723411 | 2024-08-19 12:06 UTC | custom: 100/0/10 |
sudo systemctl stop 0gchaind
cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
curl https://snapshot.kgnodes.xyz/snapshot/0gchain/snap_0gchain.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain
mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json
sudo systemctl restart 0gchaind
sudo journalctl -u 0gchaind -f --no-hostname -o cat
Checking logs
sudo journalctl -u 0gchaind -f --no-hostname -o cat
Wallet
Creating a New Wallet
0gchaind keys add <wallet_name> --keyring-backend file --eth
Importing existing wallet
0gchaind keys add <wallet_name> --recover --keyring-backend file --eth
Learning your evm adress
echo "0x$(0gchaind debug addr $(0gchaind keys show <wallet_name> -a) | grep hex | awk '{print $3}')"
Exporting private key
0gchaind keys unsafe-export-eth-key <wallet_name>
Getting faucet
Request faucet with your evm adress on website below https://faucet.0g.ai/
Network Details
Network name | 0g Newton Testnet-2 |
---|---|
Rpc Url | https://rpc-testnet.0g.ai/ |
Chain ID | 9000 |
Currency Symbol | A0GI |
Creating Validator
0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker=yourmoniker \
--chain-id=zgtendermint_16600-2 \
--commission-rate=0.1 \
--commission-max-rate=0.2 \
--commission-max-change-rate=0.01 \
--min-self-delegation=1 \
--from=<wallet_name> \
--identity="" \
--website="" \
--details="" \
--node=http://localhost:your-rpc-port \
-y
Self-Delegating
0gchaind tx staking delegate $(0gchaind keys show <wallet_name> --bech val -a) amount000000ua0gi --from <wallet_name> --node=http://localhost:your-rpc-port -y
Unjail Validator
0gchaind tx slashing unjail --from <wallet_name> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y
Deleting the Node
systemctl stop 0gchaind && \
systemctl disable 0gchaind && \
rm /etc/systemd/system/0gchaind.service && \
systemctl daemon-reload && \
cd $HOME && \
rm -rf .0gchain 0g-chain && \
rm -rf $(which 0gchaind)
sed -i '/OG_/d' ~/.bash_profile