How to setup a Chainlink node

April 12, 2022


Smart-contracts are the heart and soul of all the development happening on the Ethereum blockchain, and as more and more people develop on Ethereum, smart contracts are becoming more complex.

Sometimes a smart contract wants information about the real world, like the price of ethereum or a basketball game score. When this requirement exists, these smart contracts need to deal with external data, which is known as off-chain data that does not already reside on the blockchain, this data needs to be in the same format as on-chain data. The difficulty with connecting this outside data to blockchain in a language that both on-chain and off-chain sources can understand is limiting smart contracts' extensive usability. As a result, Oracles were introduced into the blockchain ecosystem to bring the off-chain data to on-chain. Oracles retrieve and feed external data to the blockchain and smart contracts via web APIs. But, centralized oracles can diminish the benefits of a blockchain as they can be faulty and alterable. This is where Chainlink comes into the picture. Chainlink aims to provide tamper-proof inputs and outputs for complex smart contracts and connect them to real-world events and data. Chainlink has gained a fair amount of popularity in the blockchain community. The Chainlink network is built on independent node operators, making it decentralized Oracle technology, unlike other Oracle designs that depend on a centralized entity as a gateway. The node operators are rewarded with the LINK tokens for doing high-quality, honest work. Chainlink nodes have job specifications registered with each node to execute jobs coordinated by the on-chain Oracle contracts.

Running a Chainlink node allows you to provide external data directly to smart contracts. In this guide, we will configure our Chainlink node and become a node operator on the Ethereum mainnet.


Booting our Ethereum node

For our purposes today, we could use pretty much any Ethereum client, such as Geth or OpenEthereum (fka Parity). Since that is a bit too involved for getting our Chainlink node running, we'll just grab an endpoint from QuickNode to make this easy. After you've created your ethereum endpoint, copy your WebSocket endpoint:

Screenshot of Quicknode Ethereum Endpoint

You'll need this later, so copy it and save it.

Booting your PostgreSQL instance

To run a Chainlink node we also require a PostgreSQL database instance, PostgreSQL is an open-source, object-relational database. built with keeping extensibility, data integrity, and speed in mind. Its concurrency support makes it compatible with ACID transactions and it supports dynamic loading.

If you already have a PostgreSQL database set up, get your connection string in the following form-`postgresql://$USERNAME:[email protected]$SERVER:$PORT/$DATABASE`  and you can head to the next section.

Now, let's see how we can set up our own PostgreSQL instance, we'll use DigitalOcean here.

Step 1: Create a DigitalOcean account if you don't have already and sign in.

Step 2: Click on Create in your DigitalOcean dashboard and select databases, this will take you to a page to configure your database.

Step 3: Select PostgreSQL as your database engine under 'Choose a database engine' section, under 'Choose a Cluster Configuration' section select the smallest node with 1GB-RAM-1-vCPU as you can always upscale the node later but cannot downgrade it, you can also select a Standby node in higher node plans for better reliability.

Step 4: Select a region for your database under the section 'Choose a datacenter', always choose a region your app servers are in or nearest.

Step 5: In the 'Finalize and Create' section there will be an auto-generated name of your database, you can type in a name of your choice too, select a DigitalOcean project your want this database under and even give tags.

Step 6: Now you'll see the database control panel, select "connection string" in the top-right drop-down, and a string will be displayed which we'll use in the latter part of this guide. You can also find your database control panel after you log in to your DigitalOcean account go to the Databases page, then select the name of your database cluster.

Making sure Docker is installed

By now, you should have Docker-CE installed, if not type the following in your terminal aka Command Line (for Ubuntu):

For Ubuntu:

making sure docker is installed

$ curl -sSL | 
sudo usermod -aG docker $USER

For macOS:

for macOS, Docker-CE comes with Docker Desktop which can be downloaded from Docker hub, install Docker Desktop and open the and the Docker is running.

For Windows:

for Windows, Docker-CE comes with Docker Desktop which can be downloaded from Docker hub, install Docker Desktop and open the and the Docker is running.

Related articles 12

How to Interact with Uniswap using Javascript
Apr 12, 2022

Uniswap is one of the most discussed and important projects in the DeFi space. It’s a pretty popular project for many reasons - in this guide, we will learn how to interact with the Uniswap smart contracts using a JavaScript library called

Continue reading
How to Access Bitcoin Mempool
Apr 12, 2022

Bitcoin is the father of blockchain technology. With Bitcoin started a new era of blockchain and decentralization. Bitcoin enabled everyone to make the peer-to-peer transactions they enjoy today; this guide will teach you how to get these transactions from the Bitcoin...

Continue reading
How to Make a Flash Loan using Aave
Dec 27, 2021

Aave, previously known as ETHLender, has catapulted to the forefront of the DeFi space. Aave was the first in the space to come up with the idea of a Flash Loan. Before flash loans, you would have to stake an over-collateralized...

Continue reading
Cómo realizar un Préstamo Flash en Aave
Jan 10, 2022

Aave, anteriormente conocido como ETHLender, se ha catapultado hacia la delantera en el espacio DeFi. Aave fue el primero de todos en aparecer con la idea de los Prestamos Flash. Antes de los Préstamos Flash, tenías que tener...

Continue reading
Interacting with 0x API using JavaScript
Mar 23, 2022

We have seen tremendous growth in trade volume in DEXs. With many of these coming to the market, it is tough to decide which DEX to choose when you want to swap your token for another. That's where 0x and its APIs come into the picture. It helps us to fetch the DEX with...

Continue reading
How to access Ethereum Mempool
Apr 12, 2022

On Ethereum, when a transaction is sent, before being added to a block, it resides in what is called a Mempool. To receive information about this transaction, the Mempool must be queried. This guide will demonstrate how to query a node’s mempool using QuickNode Ethereum...

Continue reading
How to Listen For Newly Minted Tokens on PancakeSwap
Apr 12, 2022

Hello reader! Today we will be diving into details about making a bot that buys newly minted tokens on the PancakeSwap DEX. Today may be your first time making a trading bot or using the BSC network, and that is okay! By the time you have read through and completed this...

Continue reading
How to Swap Tokens on Uniswap with Ethers.js
Apr 12, 2022

Not all users interact via the front-end UI when trading tokens on a decentralized exchange. Some users (or entities) trade programmatically via a smart contract or server-side scripts. This guide will demonstrate how to swap tokens on Uniswap using Javascript and the...

Continue reading