A developer is you, if you wish to consume off-chain data from APIs. You do so using Airnodes. An Airnode is a first-party oracle that pushes off-chain API data to your on-chain contract. In the diagram below, your contract is called a requester. It makes a request to the on-chain RRP protocol contract (AirnodeRrpV0.sol) that adds the request to the event logs. The off-chain Airnode then accesses the event logs, gets the API data and performs a callback to the requester.
In summary, you only need to do two things.
makeTemplateRequest()on the AirnodeRrpV0.sol contract, which returns a
- Add a
myFulfill()function (call it what you like) to your requester (your contract) where the off-chain Airnode can send the requested data when ready. The data includes the same
requestIdas the one returned at the time of making the request.
The requester (myContract.sol) makes a request to the RRP protocol contract (AirnodeRrpV0.sol) by calling
makeFullRequest()which adds the request to the event logs and returns a
requestIdto the requester.
Airnode retrieves the on-chain request from the event logs.
Airnode gathers response data from the API specified in the request.
Airnode performs a callback to a named function
myFulfill()in myContract.sol via the AirnodeRrpV0.sol function
fulfill()with the requested data and the
For a more detailed diagram see the first image in the Calling an Airnode doc.