March 20, 2021

How to setup a Chainlink node


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 QuikNode to make this easy. After you've created your ethereum endpoint, copy your WebSocket 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:$PASSWORD@$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:

$ curl -sSL | sh
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.
Ready to try QuikNode? Start your 7-day free trial

Related articles 6

Mar 20, 2021 How to access Ethereum Mempool

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 QuikNode Ethereum...

Continue reading
Mar 20, 2021 How to run a keeper bot for MKR, DAI & ETH auctions

At a high level, keeper auctions allow speculators to automatically buy assets at a discount, like the $4m+ of ETH that was bought for near-zero DAI on Black Thursday. You can see the results...

Continue reading
Mar 20, 2021 Creating a RESTful API for Compound Finance Smart Contracts

Compound finance are early pioneers in the decentralized finance space, as one of the first defi lenders. Compound offers a way to earn interest on several cryptoassets: ETH, BAT, DAI, REP, WBTC, USDC & a few others. Compound makes this possible by locking your assets...

Continue reading
Mar 20, 2021 How to stream pending transactions with ethers.js

On ethereum, before being included in a block, transactions remain in what is called a pending transaction queue, tx pool, or mempool - they all mean the same thing. Miners then select a subset of all pending transactions from this queue to mine - there are a lot of...

Continue reading
Mar 20, 2021 How to Interact with Uniswap using Javascript

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
Mar 22, 2021 How to run Trade Butler Bot with QuikNode

Bots are often made to automate the manual workflows; one such type is trading bots. Trade Butler is a very secure and popular trading bot so let’s see how we can run Trade Butler Bot backed by robust

Continue reading