Skip to main content

Demo Oracle Details

Oracle Contracts

Mainnet

ContractAddress
Push Oracle0xA42217338614B7e67D022C52D1CD38e02D619bb0
Pull Oracle0xE74B7D236A97eED9026926073cBb436638266888

Testnet

ContractAddress
Push Oracle0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0
Pull Oracle0x61D217a26D0Bff1D2b4c6f5880e621071326aadC

Oracle Configuration

Pricing MethodologyMAIR
Deviation (%) & Refresh Frequency2% and 120 seconds
Heartbeat12h

Available Asset Feeds

Asset Tickerupdates(key)Asset Markets
ETHETH/USDETH Markets
BTCBTC/USDBTC Markets
DIADIA/USDDIA Markets
USDCUSDC/USDUSDC Markets

How to Access Data

To consume price data, select the method required for your dapp. The updates method is available for Push-based oracles and request method for Pull-based oracles. The price updates are stored in both methods in an updates mapping. When accessing the updates mapping through the key BTC/USD, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is $96,014.58065403) along with the Unix timestamp of the last price update. Below are sample contracts that consume the BTC/USD price feed through both methods:

updates Method

pragma solidity ^0.8.13;

import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol";

contract DIAOracleSample {

    PushOracleReceiver public diaOracle;
    string public key = "BTC/USD";

    constructor(address _oracle) {
        diaOracle = PushOracleReceiver(payable(_oracle));
    }

    function getPrice()
    external
    view
    returns (
        uint128 timestampOflatestPrice,
        uint128 latestPrice
    ) {
        (timestampOflatestPrice, latestPrice) =
                 diaOracle.updates(key);
    }
}

request Method

// SPDX-License-Identifier: MIT
pragma solidity 0.8.29;

import { RequestOracle } from "@dia-data/contracts-spectra/RequestOracle.sol";

contract PullOracleSample {
    address public constant DIA_RECIPIENT = 0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0; // DIA testnet
    uint32 public constant DESTINATION_DOMAIN = 100640; // DIA testnet chain id

    RequestOracle public diaOracle;
    string public key = "BTC/USD";

    constructor(address _requestOracle) {
        diaOracle = RequestOracle(payable(_requestOracle));
    }

    /*
    * To calculate the request fee on each chain, you can check the script below:
    * https://github.com/diadata-org/Spectra-interoperability/blob/main/contracts/scripts/sendTestMessage.mjs#L111
    */
    function requestPrice(string memory key) external payable {
        diaOracle.request{value: msg.value}(
            DIA_RECIPIENT,
            DESTINATION_DOMAIN,
            abi.encode(key)
        );
    }

    function getPrice()
    external
    view
    returns (
        uint128 timestampOflatestPrice,
        uint128 latestPrice
    ) {
        (timestampOflatestPrice, latestPrice) =
                 diaOracle.updates(key);
    }
}

Additional Details

You can find the contract addresses for the Base bridge’s components on mainnet and testnet below:
Learn more about DIA’s cross-chain messaging layer here.

Request a Custom Oracle

DIA offers highly customizable oracles that are individually tailored to each dApp’s needs. Each oracle can be customized in the following ways, including:
  • Data Sources & Asset Feeds
  • Pricing Methodologies
  • Update Triggers (Frequency, Deviation, Heartbeat, …etc)
Get a tailored oracle for your dApp, request one below:

Support

For developer assistance, connect with the DIA team directly on Discord or Telegram.