# Instructions
This demo is a simple Airnode deployment, using a hands-on approach, to better
understand the overall deployment process of the Airnode
client image which deploys the
off-chain component of Airnode (a.k.a., the node) to a Docker
container, in this case a locally run Docker container. It uses an API endpoint
(GET /simple/price
) from
CoinGecko (opens new window) which returns the
current value of a coin. This demo does not detail the overall configuration of
an Airnode, it is just a quick start.
An Airnode Docker container deployment uses a Docker image (called client image) which in turn requires two files as input.
For the purpose of this demo these files have been created and only require a few minor changes on your part to make the deployment of the demo Airnode successful. These changes are needed to supply a chain provider url and a mnemonic.
# Install Prerequisites
Install the Docker Desktop (opens new window) and launch it.
# Project Folder
A project folder is needed for this demo. You can create it manually or download a zip file ready to go.
# Configuration
Prepare the two configuration files, config.json
and secrets.env
. By
default, the Airnode client image looks for them in the project root directory.
# config.json
This file requires no changes on your part. It has been created with just one
API endpoint. It will instruct the Airnode to attach to the Rinkeby test
network. There are a few variables this file will extract (interpolate) from
secrets.env
.
# secrets.env
Add values for each of the these fields.
CHAIN_PROVIDER_URL
: A chain provider url from a provider such as Infura (opens new window). Make sure the provider url you use is for the Rinkeby test network. Using another chain provider other than Infura is acceptable.- Sign-up or login to Infura.
- Create a new project, select the Settings tab in the project.
- Copy the URL (https) for Rinkeby under the Endpoints pick list.
AIRNODE_WALLET_MNEMONIC
: Provide the seed phrase (mnemonic) to a digital wallet. For the purpose of this demo it does not need eth in it for the Rinkeby test network. If you don't have one use the Admin CLI command generate-airnode-mnemonic to create one or another method you prefer.HTTP_GATEWAY_API_KEY
: The authentication API key that needs to be sent with every HTTP gateway request.
# Deploy
Make sure Docker is running and then run the Airnode client container from the
root of the quick-deploy-container
folder.
Run the following command to deploy the Airnode locally. Note that the version
of api3/airnode-client
matches the nodeVersion
in the config.json file.
Note that --publish HOST_PORT:CONTAINER_PORT
parameter can have different
values for the HOST_PORT
and CONTAINER_PORT
. E.g. parameter
--publish 8000:3000
would expose the web server on port 8000 on the host
machine. If run using host networking (opens new window)
you need to change the port via
gatewayServerPort
property inside config.json.
For Linux, it's recommended to use host networking (opens new window).
# Test the Airnode
# Request
Make a CURL request using the example below. Be sure to replace
HTTP_GATEWAY_API_KEY
with your key from secrets.env
.
# For Windows CMD replace line termination marker \ with ^
curl -X POST \
-d '{"parameters":{"coinIds":"api3","coinVs_currencies":"usd"}}' \
-H 'Content-Type: application/json' \
-H 'x-api-key: <HTTP_GATEWAY_API_KEY>' \
'http://localhost:3000/http-data/0x6db9e3e3d073ad12b66d28dd85bcf49f58577270b1cc2d48a43c7025f5c27af6'
2
3
4
5
6
# Response
{
"encodedValue": "0x0000000000000000000000000000000000000000000000000000000000362b30",
"rawValue": { "api3": { "usd": 3.55 } },
"values": ["3550000"]
}
2
3
4
5
Note the JSON response values
is the API3 price multiplied by
1e6
, which results from setting the
_times
reserved parameter to 1000000
in
config.json
. This manipulation is necessary in order to
correctly handle floating point numbers.
encodedValue
: This is the only field that gets sent to a requester (smart contract) on-chain. It is the encoded bytes of thevalues
field. A requester must decode it to read the response values.rawValue
: The API's response to Airnode. Presented by the HTTP gateway as a convenience. This is never sent to a requester on-chain.values
: A array of values after they are extracted and converted from theencodedValue
to the target type, in this caseapi3.usd
from_path
in reservedParameters. The HTTP gateway provides this as a convenience and never sends the decodedvalues
to a requester on-chain.
# Start and Stop
You can start and stop the Airnode with the Docker desktop application or via terminal commands.
docker stop quick-deploy-container-airnode
docker start quick-deploy-container-airnode
2
3
# Logs
You can view the Airnode's logs with the Docker desktop application or via terminal commands.
docker logs quick-deploy-container-airnode
docker logs --follow quick-deploy-container-airnode
2
3
# Remove the Airnode
When you are done with this demo you can remove it. Do so using the Docker desktop application or by using the following terminal command. When using the terminal command be sure to stop the container first if running.
# Stop the container if it is running.
docker stop quick-deploy-container-airnode
docker rm quick-deploy-container-airnode
2
3
4
# Summary
You have deployed an Airnode into a Docker container. This Airnode attaches
itself to the Rinkeby testnet as stated in the config.json
file. The Airnode,
upon deployment, started contacting the AirnodeRrpV0 contract on the Rinkeby
testnet to gather any requests made by requesters to this Airnode.
This tutorial did not address making a request on-chain as its purpose was simply to quickly deploy a functional Airnode.
Finally the API integration was tested using the HTTP gateway. You made a CURL request (using HTTP) to the HTTP gateway and Airnode queried the API provider and sent back a response. All of this was performed without accessing the blockchain.
← Overview config.json →