Polygon

Set up your Polygon Mainnet or Testnet (Mumbai) node.

In order to build the polygon node, you first need to install all of the required dependencies.

Terminal window
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y build-essential

Install the latest version of golang.

Polygon node consists of 2 layers, Heimdall and Bor. Heimdall is a fork of tendermint and runs in parallel to the Ethereum network, monitoring contracts, and Bor is a fork of go-Ethereum and producing blocks shuffled by Heimdall nodes. You need to install and run both binaries in the correct order, as explained in the following steps.

Install the latest versions for the network accordingly heimdall latest release tag and bor latest release tag

Terminal window
# These are examples - check their docs and release page to opt for the right version
HEIMDALL_RELEASE=v1.0.5
BOR_RELEASE=v1.2.8
Terminal window
https://raw.githubusercontent.com/maticnetwork/install/main/heimdall.sh |
bash -s -- $HEIMDALL_RELEASE mainnet sentry
Terminal window
https://raw.githubusercontent.com/maticnetwork/install/main/heimdall.sh |
bash -s -- $HEIMDALL_RELEASE amoy sentry
Terminal window
https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s
-- $BOR_RELEASE mainnet sentry
Terminal window
https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s
-- $BOR_RELEASE amoy sentry
Terminal window
heimdalld version --long
bor version
Terminal window
/var/lib/bor/config.toml sed -i 's|.*bootnodes =.*| bootnodes =
["enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303",
"enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303"]|g'
/var/lib/bor/config.toml chown bor /var/lib/bor
Terminal window
testnet since they’ve already been included at genesis.
Terminal window
sed -i 's/User=heimdall/User=$USER/g' /lib/systemd/system/heimdalld.service
sed -i 's/User=bor/User=$$USER/g' /lib/systemd/system/bor.service

Open the /var/lib/bor/config.toml and edit host address under jsonrpc.http

Terminal window
[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
# ipcdisable = false
# gascap = 50000000
# evmtimeout = "5s"
# txfeecap = 5.0
# allow-unprotected-txs = false
# enabledeprecatedpersonal = false
[jsonrpc.http]
enabled = true
port = 8545
host = "0.0.0.0" # change this to "0.0.0.0" from "127.0.0.1"
api = ["eth", "net", "web3", "txpool", "bor"]
vhosts = ["*"]
corsdomain = ["*"]
Terminal window
mkdir "/var/lib/bor/chaindata"
Terminal window
bash -s -- --network mainnet --client bor --extract-dir
/var/lib/bor/chaindata --validate-checksum true
Terminal window
bash -s -- --network amoy --client bor --extract-dir /var/lib/bor/chaindata
--validate-checksum true
Terminal window
bash -s -- --network mainnet --client heimdall --extract-dir
/var/lib/heimdall/data --validate-checksum true
Terminal window
bash -s -- --network amoy --client heimdall --extract-dir
/var/lib/heimdall/data --validate-checksum true
Terminal window
sudo service heimdalld start
sudo service bor start
Terminal window
journalctl -u heimdalld.service -f -n 100 -o cat
journalctl -u heimdalld-rest-server.service -f -n 100 -o cat
journalctl -u bor.service -f -n 100 -o cat

Once your Bor node is fully synced, you can run a cURL request to see the status of your node:

Terminal window
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "eth_syncing", "params":[]}' localhost:8545

If the node is successfully synced, the output from above will print {"jsonrpc":"2.0","id":1,"result":false}

In order for vald to connect to your node, your rpc_addr should be exposed in vald’s config.toml

Terminal window
start-with-bridge = true
Terminal window
start-with-bridge = true

Edit on GitHub