LogoLogo
WebsiteDIA AppRequest integration
  • DIA Oracles Overview
  • Intro to Lumina
    • How it works
    • Integrated chains
  • Data products & Tools
    • Token price feeds
  • Oracle Builder (Beta)
  • How-to guides
    • Fetch price data
      • Push based oracles
      • Pull based oracles
      • Contract Addresses
    • Run a Feeder
      • Hardware specs
      • Setting up the node
        • Docker compose
        • Docker run
        • Kubernetes
    • Stake DIA
    • Request a custom oracle
  • Reference
    • Architecture
      • Data sourcing
      • Data computation
      • Data delivery
    • Cross-chain Messaging
  • Resources
    • Audits
    • Chain information
    • Nexus Documentation
    • Community & Support
    • T&C
      • Licence Agreement
      • Contributor Covenant Code of Conduct
      • Disclaimer
Powered by GitBook
On this page
  1. How-to guides
  2. Fetch price data

Push based oracles

PreviousFetch price dataNextPull based oracles

Last updated 1 month ago

The model enables contracts to receive real-time updates based on predefined criteria such as fixed intervals, specific price deviations, or a combination of both. This design provides flexibility and efficiency for decentralized applications needing accurate and timely data.

Usage

The Oracle maintains updates as a mapping, where each key maps to a Data struct containing the latest timestamp and value.

The updates mapping is a key-value store where:

  • Key: A unique identifier, typically a string, representing the asset or data type (e.g., DIA/USD, BTC/USD).

  • Value: A Data struct containing:

    • key: The identifier of the data entry (redundant for reference but useful for integrity checks).

    • timestamp: The timestamp of the latest update.

    • value: The most recent value associated with the key.

E.g. PriceConsumer contract

contract PriceConsumer {
    Oracle public oracle;
    
    constructor(address _oracle) {
        oracle = Oracle(_oracle);
    }
    
    function getLatestPrice(string memory _key) public view returns (uint128) {
        return oracle.updates(_key).value;
    }
}

You can find demo oracles . If you want to access the oracle on Ethereum Sepolia for example, you'll pass the Push Oracle address: to the constructor above.

here
0x76a4BA6e4A40Bc613821e2a468a1e94FcCa4CE83
Push Oracle