A quick guide on how to launch the Chainlink node
What is an oracle in blockchain?
Okay, what kind of oracles are there?
Oracles can be centralized and decentralized. Centralized oracles are controlled by one person and, most often, can be located on a single server. Decentralized oracles consist of several servers controlled by different organizations, which in turn make a general oracle decision based on consensus.
The most popular oracle network is Chainlink. I’ll tell you how to deploy your oracle. Let’s start by installing the node in this article.
To run a node, you can use it on your computer for local testing or run a production version on a cloud server. In this guide, I will consider the option of running a node on a VPS.
I created on DigitalOcean droplet and Database Cluster for PostgreSQL.
For a node, Chainlink recommends the following system requirements:
- Minimum: To get started running a Chainlink node, you will need a machine with at least 2 cores and 4 GB of RAM.
- Recommended: The requirements for running a Chainlink node scale as the number of jobs your node services also scales. For nodes with over 100 jobs, you will need at least 4 cores and 8GB of RAM.
And for the database:
- Minimum: At least 2 cores, 4GB of RAM, and 100 GB of storage.
- Recommended: To support more than 100 jobs, your database server will need at least 4 cores, 16 GB of RAM, and 100 GB of storage.
We will run the node in a Docker container, for this we will install Docker itself:
curl -sSL https://get.docker.com/ | sh
sudo systemctl start docker
sudo usermod -aG docker $USER
exit
# log in again
After installing Docker, we will create a directory for Chainlink node data:
mkdir ~/.chainlink
At this stage, we need to decide on which EVM chain the node will work on.
I will be running a node for the Ethereum Mainnet. Therefore, I will specify the parameter ETH_CHAIN_ID=1. To find out whose ID is in your case, you need to find it on the website chainlist.org
Let’s create an environment file and specify all the required variables:
echo "ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=1
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*" > ~/.chainlink/.env
The full list of parameters is available in the Chainlink documentation.
In addition, we need an Ethereum client, we can run it locally or use third-party services such as Alchemy, Infura, QuikNode, Chainstack, Moralis.
I prefer to use Alchemy for its convenient tariff fees with high limits, fast responsiveness of the node, and informative dashboard.
To work with Alchemy, you need to create a new application by selecting the chain and network.
When the application was created, the analytics will be available in the dashboard. To interact with the node, we will need to export a link to connect via WebSockets.
In the settings you need to find the link: wss://<URL>
Let’s add a connection to the Ethereum node to the Chainlink config:
echo "ETH_URL=wss://<URL>" >> ~/.chainlink/.env
After setting up a connection to the blockchain, we will specify the data for connecting to the Postgres database. To do this, specify the connection string.
If you’re testing you can add
?sslmode=disable
to the end of URL. However you should never do this on a production node.
Connection string template:
postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE
Make up our own connection string and write it to the config:
echo "DATABASE_URL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE" >> ~/.chainlink/.env
Great, we’re done with configuring the config, we’ll make the first launch of the chainlink node!
The current version at the time of writing is 1.10.0. View the latest current version is available at the link.
If the node is started from under the root user, you should select only root versions of the images.
To change the version, replace the parameter with the desired version:
smartcontract/chainlink:<version>
In my case, for example, I will run the root version. To do this, I will use the following command:
cd ~/.chainlink && docker run -p 6688:6688 -v ~/.chainlink:/chainlink -it --env-file=.env smartcontract/chainlink:1.10.0-root local n
After the first launch, the node will ask you to enter the password encryption key. Enter a password of 16 characters or more.
Next, the node will ask you to enter an email and password for the operator. If everything was successful, the node will start and we will see a large number of messages in the terminal.
To launch the node later, we need to save the keys, for this, we will stop the node and perform the following actions:
Save the operator’s E-mail:
echo "user@example.com" > ~/.chainlink/.api
Save the operator’s password:
echo "password" >> ~/.chainlink/.api
And the key for data encryption:
echo "my_wallet_password" > ~/.chainlink/.password
OK, now for the second node launch we use the following command:
cd ~/.chainlink && docker run --restart=always -p 6688:6688 -d --name chainlink -v ~/.chainlink:/chainlink -it --env-file=.env smartcontract/chainlink:1.10.0-root local n -p /chainlink/.password
This command specifies the path to account data and autoruns the container after restarting the system.
Great, the node is running, now we would like to connect to it from a local device. To do this, you need to create an SSH tunnel to the server with the node.
ssh <USERNAME>@<IP> -L 6688:localhost:6688 -N
Replace the <USERNAME> and <IP> fields with your own to connect to the server via SSH.
Let’s leave the terminal tab open and open and click on the link in the browser: http://localhost:6688/
Enter the operator’s e-mail and password specified above.
Great, everything is set up successfully!
Now you can create your oracles and jobs for them.
In the next article, I created a guide for deploying the oracle and connecting it to the node.
For a more specific setup with secure access to the operator interface and the performance of oracle work, I recommend reading the following links: