Tutorial: Run your Chainlink node and add External Adapters — Get your Ethereum prices

Run your Chainlink node

There are multiple ways to run your Chainlink node, and there is an official document for that. I follow that official document and have some customization in my case (e.g I use Geth client and Rinkeby testnet for this demo). Basically, the steps will be:

Prerequisite

Create EC2 instance

EC2 server is running the Chainlink node
curl -sSL https://get.docker.com/ | sh
sudo usermod -aG docker $USER
exit #log in again to get the usermod work
sudo apt update 
sudo apt install make

Run an Ethereum Client

There are multiple Ethereum clients. In this article, I use Geth. I pull the docker image of the Ethereum client using this command

docker pull ethereum/client-go:latest
mkdir ~/.geth-rinkeby
docker run --name eth -p 8546:8546 -v ~/.geth-rinkeby:/geth -it \
ethereum/client-go --rinkeby --ws --ipcdisable \
--ws.addr 0.0.0.0 --ws.origins="*" --datadir /geth
Log of Geth-Rinkeby container

Run the Chainlink node

Run the local database using Docker PostgreSQL image

docker run -d \
--name db-chainlink \
-e POSTGRES_PASSWORD=<Input_your_password> \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v /home/ubuntu/db-chainlink/data:/var/lib/postgresql/data \
postgres:12.7-alpine3.14
mkdir ~/.chainlink-rinkeby
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' eth
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db-chainlink
vim ~/.chainlink-rinkeby/.env
ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=4
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0x01BE23585060835E02B77ef475b0Cc51aA1e0709
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
GAS_UPDATER_ENABLED=true
ALLOW_ORIGINS=*
ETH_URL=ws://<IP_of_Geth_container_get_above>:8546
DATABASE_URL=postgresql://postgres:<DB_Password_set_above>@<IP_of_database_container_get_above>:5432/postgres?sslmode=disable
DATABASE_TIMEOUT=0
cd ~/.chainlink-rinkeby && docker run -p 6688:6688 -v ~/.chainlink-rinkeby:/chainlink -it --env-file=.env smartcontract/chainlink:latest local n
The log of Chainlink container
ssh -i <path_to_your_private_key> ubuntu@<IP_of_ec2_server> -L 6688:localhost:6688 -N
Log in to Chainlink dashboard

Run External Adapters

Now, it comes to run External Adapters. First, clone the Github repository

cd ~
git clone https://github.com/smartcontractkit/external-adapters-js.git
cd ~/external-adapters-js
git checkout tags/v0.2.0 # Checkout to the most stable release
cd ~/external-adapters-js
make docker adapter=coingecko
Coingecko adapter docker image is created
cd ~/external-adapters-js
make docker adapter=coinpaprika
Coinpaprika adapter docker image is created
docker run --name coingecko -d -p 8000:8080 coingecko-adapter:latest
docker run --name coinpaprika -d -p 8001:8080 coinpaprika-adapter:latest
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' coingecko
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' coinpaprika
172.17.0.7 for coingecko container
172.17.0.8 for coinpaprika container

Create Bridges to connect to External Adapters

Return the the dashboard at http://localhost:6688 , then go to Bridges -> New Bridges and use the above IP to fill to the bridge

Create job and get the Ethereum prices

Then go to Jobs -> New Job and fill the job configuration. The below job I create is for getting the ETH to USD value, you can configure many kind of job depend on the external adapters you have. The job configuration is JSON and looks something like this

{
"name": "eth-to-usd",
"initiators": [
{
"type": "web"
}
],
"tasks": [
{
"type": "<name_of_bridges>",
"params": {
"from": "ETH",
"to": "USD"
}
}
]
}

Conclusion

Congrats! If you can come with me till this far, it is really something to me. Cause I’m quite new in terms of writing a blog, I know there are a lot of mistakes out there. I appreciate your time and your willingness to learn new things. If you need me to improve anything or any question, I am here to chat anytime. Just leave a comment and I will reply asap.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bang Le

Bang Le

Try to be a better Software Engineer everyday.