Deploying a Working Chainlink Node Using Chainstack in Minutes
By Syahrul Nizam
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.
- Install Docker-CE
- A Chainstack node (14-day trial)
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:
Running your Chainlink node
First, let’s create the directory where your Chainlink node will reside.
Next, create the .env file for the docker image
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:
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:
That’s it! You can also log in to your Chainlink console http://localhost:6688 to add in jobs.
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.