JMariadlcs / chainlink-external-adapters

End-to-end demo using Chainlink External Adapters workshop from Chainlink Hackathon Spring 2022.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chainlink-external-adapters

This is a workshop used to build an end-to-end DEMO that uses Chainlink Adapters from Chainlink Hackathon Spring 2022. The workshop followed to complete this repo is this one. The used repo that contains some implementations is this one and the cloned repo with the template used is this one.

Chainlink External Adapters allows to connect to APIs that are unreachable via de standard HTTP task. That means that you can connect any API that is avaliable on the Internet to your Smart Contract by using Chainlink nodes through Chainlink external adapters.

  • They way it work is like the one in the following figure:

  • The API we are going to ask for information is this one.
  1. Create API KEY.
  2. Clone template repo.
git clone https://github.com/thodges-gh/CL-EA-NodeJS-Template halo-ea
  1. Execute:
cd halo-ea
yarn
  1. Create .env file and paste APY_KEY
  2. Install dotenv:
npm install dotenv
  1. Modify index.js createRequest() function to call to our API.
  2. Setup authentification (function headers()).

NOTICE: index.js should look like the one included in this repo. -> Feel free to make changes in order to adapt it to your API request

How to run

  1. Execute:
yarn start
  1. Open new terminal and execute:
curl -X POST -H "content type: applications/json" "http://localhost:8080/" --data '{ "id": 1, "data": {{"playerId": "Frosty"} }'

You will get the response form the API request! ✅

Resources

About

End-to-end demo using Chainlink External Adapters workshop from Chainlink Hackathon Spring 2022.


Languages

Language:JavaScript 100.0%