Skip to main content

Useful commands

Here you can find a list of important commands for nodes setup and troubleshooting.

Frequently used commands for Bor & Heimdall

Bor

To execute Bor IPC commands, use the following syntax:

bor attach .bor/data/bor.ipc <command>
IPC CommandRPC CommandDescription
admin.peers.lengthcurl -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "net_peerCount", "params": [], "id": 74}' localhost:8545Retrieves the number of peers connected to the node.
admin.nodeInfoProvides detailed information about the node.
eth.syncingcurl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "eth_syncing","params": []}' localhost:8545Indicates whether the node is syncing (true) or not (false).
eth.syncing.highestBlock - eth.syncing.currentBlockCompares the current block of your node to the highest block.
eth.blockNumbercurl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "eth_blockNumber","params": []}' localhost:8545Returns the latest block number processed by the node.
debug.setHead("0x"+((eth.getBlock('latest').number) - 1000).toString(16))Rewinds the blockchain to 1000 blocks prior.
admin.nodeInfo.enodeRetrieves the public enode URL of the node.
eth.syncing.currentBlock * 100 / eth.syncing.highestBlockCalculates the remaining percentage for block synchronization.
eth.getBlock("latest").numbercurl http://YourIP:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"bor_getSigners", "params":["0x98b3ea"]}'Queries the height of the latest Bor block.
curl http://YourIP:8545 -X POST -H "Content-Type: application/json" --data '{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}'Retrieves the chainID.

Heimdall

CommandDescription
curl localhost:26657/net_info?Returns the number of connected peers using jq .result.n_peers.
curl -s localhost:26657/statusRetrieves Heimdall's current block height using jq .result.sync_info.latest_block_height.
curl localhost:26657/net_infoQueries the node using its moniker with grep moniker.
curl -s localhost:26657/statusChecks if Heimdall is in sync using jq .result.sync_info.catching_up.
curl -s localhost:26657/statusVerifies Heimdall's sync status using jq .result | jq .sync_info.
heimdalld unsafe-reset-allResets the database in case of issues.
curl localhost:26657/statusProvides comprehensive information about Heimdall.

Node management commands

DescriptionCommand
Locate Heimdall genesis file$CONFIGPATH/heimdall/config/genesis.json
Locate heimdall-config.toml/etc/heimdall/config/heimdall-config.toml
Locate config.toml/etc/heimdall/config/config.toml
Locate heimdall-seeds.txt$CONFIGPATH/heimdall/heimdall-seeds.txt
Start Heimdall$ sudo service heimdalld start
Start Heimdall rest-server$ sudo service heimdalld-rest-server start
Start Heimdall bridge-server$ sudo service heimdalld-bridge start
Locate Bor genesis file$CONFIGPATH/bor/genesis.json
Start Borsudo service bor start
Retrieve Heimdall logs/var/log/matic-logs/
Check Heimdall logstail -f heimdalld.log
Check Heimdall rest-server logstail -f heimdalld-rest-server.log
Check Heimdall bridge logstail -f heimdalld-bridge.log
Check Bor logstail -f bor.log

Useful configuration commands

Sync status of Heimdall

To check if Heimdall is synced, run:

curl http://localhost:26657/status

Latest block height on Heimdall

To check the latest block height on Heimdall, run:

curl localhost:26657/status

Latest block height on Bor

To check the latest block height on Bor, use:

curl http://<your ip>:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"bor_getSigners", "params":["0x98b3ea"]}'

Cleanup: deleting remnants of Heimdall and Bor

For Linux package
sudo dpkg -i matic-bor
sudo rm -rf /etc/bor
For binaries
sudo rm -rf /etc/bor
sudo rm /etc/heimdall

Terminate Bor process

For Linux
ps -aux | grep bor
sudo kill -9 <PID>
For binaries
cd CS-2003/bor
bash stop.sh

Retrieve latest peer details

To retrieve the latest peer details, run:

bor attach bor.ipc
admin.peers.forEach(function(value){
console.log(value.enode+',')
})
exit

Stop Heimdall and Bor services

For Linux packages
sudo service heimdalld stop
sudo service bor stop
For binaries
pkill heimdalld
pkill heimdalld-bridge
cd CS-2001/bor
bash stop.sh

Remove Heimdall and Bor directories

For Linux packages
sudo rm -rf /etc/heimdall/*
sudo rm -rf /etc/bor/*
For binaries
sudo rm -rf /var/lib/heimdalld/
sudo rm -rf /var/lib/bor