github.com/diadata-org/diadata@v1.4.593/documentation/oracle-documentation/aurora.md (about) 1 --- 2 title: DIA Data 3 description: How to use request data from a DIA Oracle in your Aurora Dapp using smart contracts 4 --- 5 6 # DIA Data Oracles on Aurora 7 8 ## Introduction 9 10 DIA is an ecosystem for open financial data in a financial smart contract ecosystem. 11 The target of DIA is to bring together data analysts, data providers and data users. 12 In general, DIA provides a reliable and verifiable bridge between off-chain data from various sources and on-chain smart contracts that can be used to build a variety of financial dApps. 13 DApp developers who want to leverage DIA oracles can access the published data on Aurora. 14 DIA offers data about traditional financial assets and cryptocurrencies. 15 [Read our documentation](https://docs.diadata.org) to learn about our methodologies, API, oracles, and how to contribute. 16 17 ## Supported Assets 18 19 DIA supports assets from various categories to be included into the oracle. A selection of assets is listed here: 20 21 Data Feed Name | Data Feed Query | Data Type | 22 | :-----------: | :-------------------------: | :---------------------------------: | 23 | Bitcoin | BTC/USD | Crypto Price | 24 | Ethereum | ETH/USD | Crypto Price | 25 | USDC | USDC/USD | Crypto Price | 26 | DIA Token | DIA/USD | Crypto Price | 27 28 To retrieve data, query the oracle for an asset as listed in column "Data Field Query". 29 The query string is case-sensitive. 30 31 ## Data Access 32 33 All asset prices are determined in USD according to our [methodology](https://docs.diadata.org/documentation/methodology). 34 They are denominated in a fix comma format with 5 decimals, so you need to divide them by 100000 to retrieve the actual value in USD. 35 Where applicable, the oracle also provides information on circulating supply and the timestamp of data collection. 36 The query in the smart contract is realized with the symbol of the asset. 37 38 ### Smart Contract 39 40 DIA data is published in the `DIAOracle` smart contract. 41 By querying the `getValue()` function you can retrieve the requested data. 42 You can interact with our contract in the [blockchain explorer](https://explorer.mainnet.aurora.dev/address/0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f/transactions), where you can query for any supported asset. 43 44 The contract takes the symbol name of the asset as input, e.g., `BTC` and returns a tuple of the timestamp of the last update and the actual value. 45 46 ### Write your own DApp 47 48 To access oracle data, you can either use the explorer above or write your own contract and reference the oracle. 49 The following snippet shows how to retrieve the price of an asset (e.g. `DIA`) measured in another asset (BTC) using a wrapper smart contract. 50 On Aurora, you can initialize the oracle address in your wrapper contract by calling `setOracleAddress()` with the address of our deployed demo contract `0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f`. 51 52 ``` 53 pragma solidity 0.7.4; 54 55 contract DIAOracle { 56 mapping (string => uint256) public values; 57 address oracleUpdater; 58 59 event OracleUpdate(string key, uint128 value, uint128 timestamp); 60 event UpdaterAddressChange(address newUpdater); 61 62 constructor() { 63 oracleUpdater = msg.sender; 64 } 65 66 function setValue(string memory key, uint128 value, uint128 timestamp) public { 67 require(msg.sender == oracleUpdater); 68 uint256 cValue = (((uint256)(value)) << 128) + timestamp; 69 values[key] = cValue; 70 emit OracleUpdate(key, value, timestamp); 71 } 72 73 function getValue(string memory key) public view returns (uint128, uint128) { 74 uint256 cValue = values[key]; 75 uint128 timestamp = (uint128)(cValue % 2**128); 76 uint128 value = (uint128)(cValue >> 128); 77 return (value, timestamp); 78 } 79 80 function updateOracleUpdaterAddress(address newOracleUpdaterAddress) public { 81 require(msg.sender == oracleUpdater); 82 oracleUpdater = newOracleUpdaterAddress; 83 emit UpdaterAddressChange(newOracleUpdaterAddress); 84 } 85 } 86 87 contract DiaAssetBtcOracle { 88 DIAOracle oracle; 89 address owner; 90 91 constructor() public { 92 owner = msg.sender; 93 } 94 95 function setOracleAddress(address _address) public { 96 require(msg.sender == owner); 97 oracle = DIAOracle(_address); 98 } 99 100 function getAssetBtcRate(string asset) constant public returns (uint256) { 101 (uint assetPrice,) = oracle.getValue(asset); 102 (uint btcPrice,) = oracle.getValue("BTC/USD"); 103 return (assetPrice / btcPrice); 104 } 105 106 } 107 ``` 108 109 #### Deployed Addresses 110 111 | Chain name | Oracle Contract Address | Update Frequency | 112 | :------------ | :-------------------------------------------: | :--------------: | 113 | Aurora | `0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f` | 1 hour | 114 115 ### Github and Contact 116 117 DIA provides a broad range of assets. You can find an overview in the DIA documentation [here](https://docs.diadata.org/documentation/oracle-documentation). 118 All our code is open-source and can be found on our [Github repositoy](https://github.com/diadata-org/diadata). 119 For the deployment of specific oracles (source/methodology/frequency) please [contact the DIA team](mailto:bd@diadata.org). 120 121 You can follow us on [Telegram](https://t.me/DIAdata_org), [Github](https://github.com/diadata-org), and [Medium](https://medium.com/dia-insights).