On the NEAR blockchain, DIA operates an oracle that can fetch quotations 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.
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.
We will extend the NEAR oracle with additional data from our API in the future.
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
After that, you can build the oracle consumer with
npm run buildand start the oracle consumer with
An example request and response for the asset DIA (can be configured in the source file) looks like this
[email protected]% node dist/test/quote-make-request
near.call quote-test-client.dia-test.testnet make_request
near.view quote-test-client.dia-test.testnet get_callback_response