Access the Oracle
This page contains an overview over how to access crypto asset information using the DIA oracle system
Last updated
This page contains an overview over how to access crypto asset information using the DIA oracle system
Last updated
Here 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: 0xa935...5856.
Access any DIA oracle smart contract.
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.
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.
The oracle exists on various blockchains and contains information about crypto assets. You can access a price quotation (see sources and methodology) and the current circulating supply as well as the timestamp of the last update.
See DIA's oracle structure for more information:
You can find DIA's oracle integration samples in Solidity and Vyper languages for the EVM-based chains.
Here is an example of how you can integrate DIA's oracle into your smart contract with Solidity:
Find the detailed description of the functions and how to run tests on our GitHub page:
Here is an example of how you can integrate DIA's oracle into your smart contract with Vyper:
Find the detailed description of the functions and how to run tests on our GitHub page
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
.
Returns the price of a specified asset.
Parameters:
Return Values:
Checks if the oracle price is older than maxTimePassed
Parameters:
Return Values:
Find a detailed integration example and how to run a test on our GitHub page:
The oracle contains information about price quotations of crypto assets from CoinMarketCap and Coingecko. You can access quotations for the top 50 assets ranked by market capitalization. You can execute an oracle call as follows:
Access DIA's guest quotation oracles (find them here).
Call getValue(key)
where key
is the symbol for the asset in capital letters, for instance BTC
for Bitcoin. You can use the "Read" section on Etherscan to execute this call.
The response of the call contains two values:
The current asset price in USD.
The UNIX timestamp of the last oracle update.
You can find out more about 3rd party data here:
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
oracle
address
Address of the oracle that we want to use
key
string
The asset that we want to use e.g. "ETH/USD"
Price
uint128
Price of the specified asset returned by the DIAOracle
oracle
address
Address of the oracle that we want to use
key
string
The asset that we want to use e.g. "ETH/USD"
maxTimePassed
uint128
The maximum acceptable time passed in seconds since the the price was updated
Price
uint128
Price of the specified asset returned by the DIAOracle
inTime
uint128
A boolian that is true
if the price was updated at most maxTimePassed seconds ago, otherwise false