Skip to main content

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.
Here’s an example of a DIAOracleSample contract that consumes the BTC/USD price feed:
Push oracles update on a deviation or heartbeat. Between updates, or if updates stop, the stored price keeps aging. Always check the timestamp before using it. See Check Price Freshness.
To deploy the contract, provide the oracle address for the destination chain you’re reading from. You can find the contract addresses in the chain-specific guides. As an example, if you want to access the oracle on Ethereum Sepolia, you’ll pass the Push Oracle address: 0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0 to the constructor above. You can also change the key to any of the supported assets (e.g. DIA/USD).