NEAR Request Oracle
This page contains an overview on how to interact with the NEAR Request oracle
On the NEAR blockchain, DIA operates an oracle that can fetch any quotation from the DIA API. The oracle follows a request/response pattern, i.e., an on-chain NEAR contract requests data from the DIA API which is then promptly served by the oracle as a callback.
The latest oracle addresses are listed here.
How to use the oracle
The oracle can be used by interfacing it with a client for quotations, that takes the callbacks and processes the data. An example deployment can be seen here on the NEAR testnet. The corresponding source code is located in this repository.
Follow the instructions in its README to learn how to interact with the DIA oracle on the NEAR blockchain. There, the exact steps are described for getting a client up and running that is served quotations using the request oracle.
Usage Example
You can test the oracle by querying a price quotation using code from the example repository. For that, checkout the repository and install dependencies using npm install
After that, you can build the oracle consumer with npm run build
and start the oracle consumer with node dist/test/quote-make-request
An example request and response for the asset DIA (can be configured in the source file) looks like this:
Request:
Response: