Preparations
To continue, we can update the packages by running the following commands in the terminal. The first part of the command (sudo apt update ) updates the package lists for upgrades, and the second part (sudo apt upgrade -y ) actually performs the upgrades with the โ-yโ flag allowing for automatic confirmation of prompts during the upgrade process:
Copy sudo apt-get update && sudo apt-get upgrade -y
Execute .bashrc
and .bash_profile
files:
Copy source $HOME /.bashrc
source $HOME /.bash_profile
Install packages:
Copy apt install snap unzip wget jq
Install Go:
Copy 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" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME /.bash_profile && \
source $HOME /.bash_profile && \
go version
Installation
Clone GitHub repository:
Copy git clone -b v0.1.0 https://github.com/0glabs/0g-chain.git
Move to 0g-chain
folder:
Switch to testnet branch:
Copy git checkout origin/v0.1.0
Install 0gchaind
:
Check version:
Run:
Copy cd && source .profile
Set Chain ID and node tcp:
Copy 0gchaind config chain-id zgtendermint_16600-1
0gchaind config node tcp://localhost:26657
Initialize node:
Change <your_moniker> for your node name.
Copy 0gchaind init < your_monike r > --chain-id zgtendermint_16600-1
If everything went ok, should look like this:
Download genesis
file:
Copy rm ~/.0gchain/config/genesis.json
wget -P ~/.0gchain/config https://github.com/0glabs/0g-chain/releases/download/v0.1.0/genesis.json
Check genesis:
Copy sha256sum $HOME /.0gchain/config/genesis.json
Output should be:
cc862760abd4cebb91935e7506a745a251074cdd44148a5c9ae4ee7539dd8d0a /root/.0gchain/config/genesis.json
Validate genesis:
Copy 0gchaind validate-genesis
Output should be:
File at /root/.0gchain/config/genesis.json is a valid genesis file
Check validator state:
Copy cd && cat .0gchain/data/priv_validator_state.json
Should be at the beginning:
Copy {
"height" : "0" ,
"round" : 0,
"step" : 0
}
Add seeds and peers:
Copy SEEDS="c4d619f6088cb0b24b4ab43a0510bf9251ab5d7f@54.241.167.190:26656,44d11d4ba92a01b520923f51632d2450984d5886@54.176.175.48:26656,f2693dd86766b5bf8fd6ab87e2e970d564d20aff@54.193.250.204:26656,f878d40c538c8c23653a5b70f615f8dccec6fb9f@54.215.187.94:26656"
PEERS="6cdd50ed6e958269c259ffc4db17509e15e381bb@185.209.223.10:16656,3a8a28c734a4d32052065d9f6006c14dfa7a4e4e@37.27.59.176:18456,a4055b828e59832c7a06d61fc51347755a160d0b@157.90.33.62:21656,cd529839591e13f5ed69e9a029c5d7d96de170fe@46.4.55.46:34656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.0gchain/config/config.toml
Add pruning:
Copy pruning = "custom"
pruning_keep_recent = "1000"
pruning_interval = "10"
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME /.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME /.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME /.0gchain/config/app.toml
Downdload addrbook
file:
Copy curl -L https://snapshot.validatorvn.com/og/addrbook.json > $HOME /.0gchain/config/addrbook.json
Create service file:
Copy tee /etc/systemd/system/0gd.service > /dev/null << EOF
[Unit]
Description=0G Node
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=/root/go/bin/0gchaind start --home /root/.0gchain
Restart=on-failure
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
Reload daemon:
Copy systemctl daemon-reload
Enable 0gd.service
:
Start ogd.service
:
Check status:
If everything went ok, should look like this:
Wait for synchronization.
Check sync status:
Copy 0gchaind status | jq .SyncInfo
or just catching up:
Copy 0gchaind status | jq .SyncInfo.catching_up
When fully synced should be false .
Create wallet:
Change <key_name> with Your wallet name.
Copy 0gchaind keys add < key_nam e > --eth
Enter password (passphrase).
Save mnemonic and wallet address.
Check and save your HEX address:
Change <WALLET_NAME> to what youโve chosen in previous step.
Copy echo "0x$( 0gchaind debug addr $( 0gchaind keys show < WALLET_NAM E > -a ) | grep hex | awk '{print $3}')"
Save it.
Go to faucet and claim test tokens.
It gives only 0.1evmos per day, you can claim only once per day.
Check balance:
Change <WALLET_NAME> to what youโve chosen in step 25.
Copy 0gchaind q bank balances $( 0gchaind keys show < WALLET_NAM E > -a )
Create validator:
Change:
YOUR_MONIKER with the name of you validator;
WALLET_NAME to what youโve chosen in step 25.
Copy 0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--pubkey=$( 0gchaind tendermint show-validator) \
--moniker= "YOUR_MONIKER" \
--chain-id=zgtendermint_16600-1 \
--commission-rate=0.05 \
--commission-max-rate=0.20 \
--commission-max-change-rate=0.01\
--details "psi.crypto community" \
--min-self-delegation= "1" \
--from=WALLET_NAME \
--gas=auto \
--gas-adjustment=1.4
-y
Delegate to your validator:
Change <WALLET_NAME> with your wallet name,
Change <MONIKER> with moniker from previous step.
Copy 0gchaind tx staking delegate $(0gchaind keys show <MONIKER> --bech val -a) 1000000ua0gi --from <WALLET_NAME> --gas=auto --gas-adjustment=1.4 -y
Update Node
Stop service file:
Copy sudo systemctl stop 0gd
Remove the outdated files:
Copy rm $HOME /.0gchain/config/addrbook.json $HOME /.0gchain/config/genesis.json
Reset the data:
Copy 0gchaind tendermint unsafe-reset-all --home $HOME /.0gchain
Your node is now in a pristine state while keeping the original priv_validator.json
and config.toml
.
Restart service file:
Copy sudo systemctl restart 0gd
Useful commands
Unjail:
Copy 0gchaind tx slashing unjail --from < key_nam e > --gas=500000 --gas-prices=7ua0gi โy
Check list of active validators:
Copy 0gchaind q staking validators -o json --limit=1000 | jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' | jq -r '.tokens + " - " + .description.moniker' | sort -gr | nl
Check list of inactive validators:
Copy 0gchaind q staking validators -o json --limit=1000 | jq '.validators[] | select(.status=="BOND_STATUS_UNBONDED")' | jq -r '.tokens + " - " + .description.moniker' | sort -gr | nl
Delegate to validator:
Copy 0gchaind tx staking delegate $(0gchaind keys show <MONIKER> --bech val -a) AMOUNTua0gi --from <WALLET_NAME> --gas=auto --gas-adjustment=1.4 -y
Send transaction:
Change <SENDER_WALLET> , <RECEIVER_WALLET> , AMOUNT .
Copy 0gchaind tx bank send < SENDER_WALLE T > < RECEIVER_WALLE T > AMOUNTua0gi --gas=95000 --gas-prices=7ua0gi -y
Delete node
Copy sudo systemctl stop 0gd
sudo systemctl disable 0gd
rm /etc/systemd/system/0gd.service
rm -rf 0g-chain
rm -rf .0gchain
Last updated 2 months ago