Chainlink Retryable External Adapter Template
This template provides a basic framework for developing Chainlink external adapters in NodeJS. Comments are included to assist with development and testing of the external adapter. Once the API-specific values (like query parameters and API key authentication) have been added to the adapter, it is very easy to add some tests to verify that the data will be correctly formatted when returned to the Chainlink node. There is no need to use any additional frameworks or to run a Chainlink node in order to test the adapter.
Creating your own adapter from this template
Clone this repo and change "MyProject" below to the name of your project
git clone https://github.com/thodges-gh/retryable-external-adapter.git MyProject
Enter into the newly-created directory
cd MyProject
You can remove the existing git history by running:
rm -rf .git
Now make changes to the adapter to suit your needs. There are test helpers included in test/helpers/
so that you can mock responses from the endpoint without having to hit the API each time you run tests.
Input Params
coin
: The asset to querymarket
: The currency to convert to
Output Format
{
"jobRunID": "278c97ffadb54a5bbb93cfec5f7b5503",
"data": {
"USD": 8
},
"statusCode": 200
}
Install
yarn install
Test
yarn test
Docker
If you wish to use Docker to run the adapter, you can build the image by running the following command:
docker build . -t retryable-adapter
Then run it with:
docker run -p 8080:8080 -it retryable-adapter:latest
Create the zip
zip -r cl-ea.zip .
Install to AWS Lambda
- In Lambda Functions, create function
- On the Create function page:
- Give the function a name
- Use Node.js 12.x for the runtime
- Choose an existing role or create a new one
- Click Create Function
- Under Function code, select "Upload a .zip file" from the Code entry type drop-down
- Click Upload and select the
cl-ea.zip
file - Handler should remain index.handler
- Add the environment variable (repeat for all environment variables):
- Key: API_KEY
- Value: Your_API_key
- Save
Install to GCP
- In Functions, create a new function, choose to ZIP upload
- Click Browse and select the
cl-ea.zip
file - Select a Storage Bucket to keep the zip in
- Function to execute: gcpservice
- Click More, Add variable (repeat for all environment variables)
- NAME: API_KEY
- VALUE: Your_API_key