Using DIAOracleV2 Interface
The following is an example of how to retrieve price value from a standard DIA oracle. For the purpose of this example, we will be using the following demo oracle on Ethereum: 0xCD5F…f3cB.1
Access any DIA oracle smart contract.
2
Call
getValue(pair_name) with pair_name being the full pair name such as BTC/USD. You can use the “Read” section on Etherscan to execute this call.3
The response of the call contains four values:
- The current asset’s price in USD with a fix-comma notation of 8 decimals.
- The UNIX timestamp of the last oracle update.
GitHub - diadata-org/DIA-integration-sample
Solidity integration example
Using Solidity Library
DIA has a dedicated Solidity library to facilitate the integration of DIA oracles in your own contracts. The library consists of two functions,getPrice and getPriceIfNotOlderThan.
Access the library
Methods
getPrice
Return Values:
getPriceIfNotOlderThan
maxTimePassed
Parameters:
Return Values:
Find a detailed integration example and how to run a test on our GitHub page: