Metis RPC endpoint
From Chainlink Community Wiki
Metis RPC endpoint detailsThis is a general guide on deploying an Metis RPC endpoint for your Chainlink Node(s).Official Metis Docs are available here |
NOTE
Metis RPC endpoints:
You Chainlink node has two connections methods. Websocket and HTTP.
As these can vary between networks, the default values for an Metis node are:
Websocket ws://<your_ip_address>:8546
HTTPhttp://<your_ip_address>:8545
Install Docker-CE
Install dependencies first.
sudo apt update && sudo apt upgrade && sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
Now, we'll need to get our aptitude sources updated to include the Docker-CE repository.
Now, we'll need to get our aptitude sources updated to include the Docker-CE repository.
These commands must be run as root.
sudo su
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
Once we have added the repo and the necessary key, we want to exit the root user.
exit
NOTE
$
if you're a non-root user. If you're in an elevated (root) TTY session, your shell prompt will display a #
Since we've modified our aptitude sources, we'll need to update them before we can install docker-ce
sudo apt update && sudo apt install docker-ce
Now that we have Docker-CE installed, we'll need to add our user to the docker group.
(The prevents us from having to run docker commands with elevated (root) permissions)
sudo usermod -aG docker $USER
Then, we will install docker-compose
sudo apt install -y docker-compose
Next, we'll get our Metis node deployed and synced.
Deploy Metis RPC Node
First, we'll need to create a new directory house the container volume.
mkdir ~/.metis-data
We'll need to clone the Metis repo
git clone https://github.com/ericlee42/metis-replica-node-guide
Navigate into the newly cloned directory.
cd metis-replica-node-guide
Then we'll copy the example docker-compose configuration to a used file.
cp docker-compose-mainnet.yml docker-compose.yml
Be sure to update DATA_TRANSPORT_LAYER__L1_RPC_ENDPOINT in the newly copied coker-compose file with either your local Ethereum RPC endpoint if you have one, or a reliably hosted option if you don't.
For example, if your local ETH Mainnet RPC endpoint was at http://10.10.10.111:8545, you'd update the file to
DATA_TRANSPORT_LAYER__L1_RPC_ENDPOINT=http://10.10.10.111:8545
.
With the file updated, we can start the container.
docker-compose up -d dtl
Once that has started successfully, we'll then want to start the L2 service
docker-compose up -d l2geth
You can check your local RPC node's sync status and latest block against the explorer with the following bash script:
#!/bin/bash # blue foreground blue_fg=$(tput setaf 6) # reset to default reset=$(tput sgr0) # SET VARS BLOCK_HEIGHT=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_blockNumber"}' | jq -r .result) ANDROMEDA_METIS_BLOCK_HEIGHT=$(curl -s -d "module=block&action=eth_block_number" -X POST https://andromeda-explorer.metis.io/api | jq -r .result) IS_SYNCING=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_syncing"}' | jq .) echo "----------------------" echo "RPC Node block height: ${blue_fg}$((BLOCK_HEIGHT))${reset}" echo "Metis Explorer block height: ${blue_fg}$((ANDROMEDA_METIS_BLOCK_HEIGHT))${reset}" VAR1=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_syncing"}' | jq .result) VAR2="false" if [ "$VAR1" = "$VAR2" ]; then echo "Sync Status: ${blue_fg}Node is synced.${reset}" else echo "${blue_fg}Node is ${yellow_fg}NOT${blue_fg} synced.${reset}" fi