Polygon

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

Prerequisites

Install required dependencies

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

1. Update and install build-essential

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

2. Install golang

Install the latest version of golang.

Install the Polygon node

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

# 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

1. Install Heimdall

curl -L https://raw.githubusercontent.com/maticnetwork/install/main/heimdall.sh | bash -s -- $HEIMDALL_RELEASE mainnet sentry
curl -L https://raw.githubusercontent.com/maticnetwork/install/main/heimdall.sh | bash -s -- $HEIMDALL_RELEASE amoy sentry

2. Install Bor

curl -L curl -L https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s -- $BOR_RELEASE mainnet sentry
curl -L curl -L https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s -- $BOR_RELEASE amoy sentry

Check Versions

heimdalld version --long
bor version

Setup and configure node

1. Configure Bor seeds

sed -i 's|.*\[p2p.discovery\]|  \[p2p.discovery\] |g' /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
# The Bor seeds don’t need to be configured manually for Amoy testnet since they’ve already been included at genesis.

2. Update service config user permission

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

3. Open port to public

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

[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 = ["*"]

Sync from snapshot

Bor

mkdir "/var/lib/bor/chaindata"
curl -L https://snapshot-download.polygon.technology/snapdown.sh | bash -s -- --network mainnet --client bor --extract-dir /var/lib/bor/chaindata --validate-checksum true
curl -L https://snapshot-download.polygon.technology/snapdown.sh | bash -s -- --network amoy --client bor --extract-dir /var/lib/bor/chaindata --validate-checksum true

Heimdall

curl -L https://snapshot-download.polygon.technology/snapdown.sh | bash -s -- --network mainnet --client heimdall --extract-dir /var/lib/heimdall/data --validate-checksum true
curl -L https://snapshot-download.polygon.technology/snapdown.sh | bash -s -- --network amoy --client heimdall --extract-dir /var/lib/heimdall/data --validate-checksum true

Start the services

sudo service heimdalld start
sudo service bor start

Check logs

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

Verify RPC

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

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}

Configure vald

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

[[axelar_bridge_evm]]
name = "polygon"
rpc_addr = "http://IP:PORT"
start-with-bridge = true
[[axelar_bridge_evm]]
name = "polygon"
rpc_addr = "http://IP:PORT"
start-with-bridge = true
Edit this page