# Polygon (https://docs.axelar.dev/infrastructure/chain-nodes/polygon)



<Callout title="Consensus chain">
  This chain is verified by Axelar validators. Before setting up this node,
  [set up your Axelar validator](https://docs.axelar.dev/llms.mdx/infrastructure/validators/content.md).
  Once the node is running, connect it to `vald` as described in [Verify consensus
  chains](https://docs.axelar.dev/llms.mdx/infrastructure/verifiers/consensus-chains/content.md).
</Callout>

<Callout type="warn" title="Check the official documentation">
  The node setup steps below follow Polygon's own documentation at the time of
  writing and may be out of date. Check the [official
  documentation](https://docs.polygon.technology/pos/how-to/full-node/full-node-binaries) before you start. The Axelar-specific steps (connecting
  the node to `vald` or `ampd`) are maintained here.
</Callout>

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

## Prerequisites [#prerequisites]

* [Setup your Axelar validator](https://docs.axelar.dev/llms.mdx/infrastructure/validators/content.md)
* Minimum hardware requirements: 4-8+ core CPU , 16-32GB RAM, 2TB+ SSD free storage space.
* MacOS or Ubuntu 18.04+
* Build-essential packages
* Golang 1.17+
* [Official Documentation](https://docs.polygon.technology/pos/how-to/full-node/full-node-binaries)

## Install required dependencies [#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` [#1-update-and-install-build-essential]

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

### 2. Install `golang` [#2-install-golang]

Install the [latest version of golang](https://go.dev/doc/install).

## Install the Polygon node [#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](https://github.com/maticnetwork/heimdall/tags) and [bor latest release tag](https://github.com/maticnetwork/bor/tags)

```bash
# 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 [#1-install-heimdall]

<Tabs items="[&#x22;Mainnet&#x22;,&#x22;Testnet&#x22;]">
  <Tab value="Mainnet">
    ```bash curl -L
    https://raw.githubusercontent.com/maticnetwork/install/main/heimdall.sh |
    bash -s -- $HEIMDALL_RELEASE mainnet sentry 
    ```
  </Tab>

  <Tab value="Testnet">
    ```bash curl -L
    https://raw.githubusercontent.com/maticnetwork/install/main/heimdall.sh |
    bash -s -- $HEIMDALL_RELEASE amoy sentry 
    ```
  </Tab>
</Tabs>

### 2. Install Bor [#2-install-bor]

<Tabs items="[&#x22;Mainnet&#x22;,&#x22;Testnet&#x22;]">
  <Tab value="Mainnet">
    ```bash curl -L curl -L
    https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s
    -- $BOR_RELEASE mainnet sentry 
    ```
  </Tab>

  <Tab value="Testnet">
    ```bash curl -L curl -L
    https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s
    -- $BOR_RELEASE amoy sentry 
    ```
  </Tab>
</Tabs>

## Check Versions [#check-versions]

```bash
heimdalld version --long
bor version
```

## Setup and configure node [#setup-and-configure-node]

### 1. Configure Bor seeds [#1-configure-bor-seeds]

<Tabs items="[&#x22;Mainnet&#x22;,&#x22;Testnet&#x22;]">
  <Tab value="Mainnet">
    ```bash 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 
    ```
  </Tab>

  <Tab value="Testnet">
    ```bash # The Bor seeds don’t need to be configured manually for Amoy
    testnet since they’ve already been included at genesis. 
    ```
  </Tab>
</Tabs>

### 2. Update service config user permission [#2-update-service-config-user-permission]

```bash
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 [#3-open-port-to-public]

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

```bash
[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 [#sync-from-snapshot]

### Bor [#bor]

```bash
mkdir "/var/lib/bor/chaindata"
```

<Tabs items="[&#x22;Mainnet&#x22;,&#x22;Testnet&#x22;]">
  <Tab value="Mainnet">
    ```bash curl -L https://snapshot-download.polygon.technology/snapdown.sh |
    bash -s -- --network mainnet --client bor --extract-dir
    /var/lib/bor/chaindata --validate-checksum true 
    ```
  </Tab>

  <Tab value="Testnet">
    ```bash curl -L https://snapshot-download.polygon.technology/snapdown.sh |
    bash -s -- --network amoy --client bor --extract-dir /var/lib/bor/chaindata
    --validate-checksum true 
    ```
  </Tab>
</Tabs>

### Heimdall [#heimdall]

<Tabs items="[&#x22;Mainnet&#x22;,&#x22;Testnet&#x22;]">
  <Tab value="Mainnet">
    ```bash curl -L https://snapshot-download.polygon.technology/snapdown.sh |
    bash -s -- --network mainnet --client heimdall --extract-dir
    /var/lib/heimdall/data --validate-checksum true 
    ```
  </Tab>

  <Tab value="Testnet">
    ```bash curl -L https://snapshot-download.polygon.technology/snapdown.sh |
    bash -s -- --network amoy --client heimdall --extract-dir
    /var/lib/heimdall/data --validate-checksum true 
    ```
  </Tab>
</Tabs>

## Start the services [#start-the-services]

```bash
sudo service heimdalld start
sudo service bor start
```

## Check logs [#check-logs]

```bash
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 [#verify-rpc]

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

```bash
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 [#configure-vald]

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

<Tabs items="[&#x22;Mainnet&#x22;,&#x22;Testnet&#x22;]">
  <Tab value="Mainnet">
    ```bash [[axelar_bridge_evm]] name = "polygon" rpc_addr = "http://IP:PORT"
    start-with-bridge = true 
    ```
  </Tab>

  <Tab value="Testnet">
    ```bash [[axelar_bridge_evm]] name = "polygon" rpc_addr = "http://IP:PORT"
    start-with-bridge = true 
    ```
  </Tab>
</Tabs>


---

All pages of these docs, as Markdown: https://docs.axelar.dev/llms.txt