Deploying a Working Chainlink Node Using Chainstack in Minutes

This article first appeared in Coinmonks.

Chainlink nodes are oracles that allow Smart Contracts that reside on the Ethereum Blockchain to interact with external APIs. Prior to the creation of Chainlink nodes, it was impossible for Smart Contract to access these APIs, thus limiting their functionality.

The importance of Chainlink nodes cannot be underestimated — smart contracts can now be much more fluid & flexible, allowing it to truly be smart by accessing data sets from outside the blockchain.

In this tutorial, we will deploy our own Chainlink node and then seamlessly get it to connect to an Ethereum node created via Chainstack (I work there). This will be done on the Ropsten network.

Nodes created by Chainstack only need minutes to fully sync, meaning that your Chainlink node can be quickly deployed as well.

Requirements

  1. Install Docker-CE
  2. A Chainstack node (14-day trial)

End Point

Let’s start by getting the websocket endpoint of your Ethereum node. This can easily be obtained from your Chainstack console. If you’re not sure on how to create an Ethereum node on Chainstack, visit my previous tutorial.

Take note of the WSS (websocket) endpoint:

Endpoints page in the Chainstack console

Running your Chainlink node

First, let’s create the directory where your Chainlink node will reside.

mkdir ~/.chainlink-ropsten

Next, create the .env file for the docker image

echo "ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=3
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0x20fe562d797a42dcb3399062ae9546cd06f63280
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*" > ~/.chainlink-ropsten/.env

The “LINK_CONTRACT_ADDRESS” variableis set to “0x20fe562d797a42dcb3399062ae9546cd06f63280” , which is the contract address for test Chainlink tokens on the Ropsten testnet. Thus, change this accordingly when using other testnets or mainnet.

Since we’re running the Ethereum Client on Chainstack and not on a local machine copy & edit the code below with your WSS endpoint.

echo "ETH_URL=WSS_ENDPOINT" >> ~/.chainlink-ropsten/.env

where “WSS_ENDPOINT” is the value obtained from the Chainstack console.

Starting the node

Run the code below in your terminal:

cd ~/.chainlink-ropsten && docker run -p 6688:6688 -v ~/.chainlink-ropsten:/chainlink 
-it --env-file=.env smartcontract/chainlink local n

Congratulations, your node should be running! Your terminal window should look something like this:

Creation of a Chainlink node

Chainlink nodes will manage and use their own Ethereum keys, and will not use the Ethereum keys managed by the Ethereum client. You will be prompted for a password, and this password represents the Ethereum Keystore file used by your Chainlink node.

Once you’ve set the node password, you can create the first API user for your chainlink node. As an API user, you will be able to create new jobs for smart contracts to make API calls to.

Once the API user is created, the Chainlink node should receive block headers from the Chainstack Ethereum node:

Chainlink listening to Chainstack

That’s it! You can also log in to your Chainlink console http://localhost:6688 to add in jobs.

Conclusion

Feel free to play around and deploy your own jobs and interact with the node. You can head over to the Chainlink documentation on how to fulfill requests.


Explore Chainstack

When Will the Blockchain Rubber Meet the Adoption Road?

Let me start by thanking IMDA and the engaging participants at this month’s Blockchain Discovery Day in Singapore. In a field that is moving at a blistering pace, and a world where everything real-time is the norm…

Chainstack
Chainstack
Oct 7

Trust Yourself – Final Part of the Trust Trilogy

In part 2 of the Trust Trilogy, I ended with the promise of larger ecosystems and markets made possible through a simple mind-shift, where collaboration is the norm and the blockchain is the default trusted execution environment.

Chainstack
Chainstack
Jul 9
Chainstack uses cookies to provide you with a secure and
personalized experience on its website. Learn more.