LogoLogo
GitHub
  • Quickstart
    • What is eOracle?
    • eOracle Vision
    • Use eOracle
  • Build on eOracle
    • Introduction to eOracle Stack
    • What is an OVS
    • eOracle Features
    • eOracle Data Processing Flow
    • Builders Workflow
      • Set-up
      • Off-chain Computation
      • On-chain Components
      • Target Chains Publishing
    • Smart Contracts Overview
      • eOracle Chain contracts
      • Target Contracts
    • Aggregation Library
      • Median
      • Clustering
      • TWAP
      • Robust Aggregation 101
    • eOracle Cryptographic Broadcaster
    • Incentives Management
      • 🥢On-chain-Subjective Slashing Framework
    • Active Specialized Blockchain Oracles
      • EtherOracle - Peg Securing Oracle by Etherfi
      • Pulse - Risk Oracle By Bitpulse
      • ECHO - Social Media Oracle
      • Borsa - Intent Optimisation
  • ePRICE
    • Introduction to ePRICE
    • Integration Guide
    • Risk Management and Market Integrity
    • Feed Addresses
      • Arbitrum
      • Arbitrum Sepolia
      • Base
      • Base Sepolia Testnet
      • Berachain
      • Blast
      • BNB Smart Chain
      • BOB
      • B Squared
      • B Squared Testnet
      • Hemi
      • Ink Sepolia
      • Ink Mainnet
      • Linea
      • Linea Sepolia
      • Manta
      • Manta Sepolia Tesnet
      • Mode
      • Mode Testnet
      • Monad Testnet
      • Morph
      • Morph Holesky
      • Polygon zkEVM
      • Polygon zkEVM Cardona Testnet
      • Plume
      • Plume Testnet
      • Scroll
      • Soneium
      • Sonic
      • Soneium Testnet
      • TAC Turin Testnet
      • Taiko Mainnet
      • Unichain
      • Unichain Sepolia
      • Zircuit
      • Zircuit Testnet
      • zkLink Nova Mainnet
    • API Reference
      • 🧩Examples
      • 🧩Off-chain Examples
    • Advanced
      • 🤖Automating eOracle consumption
      • 💱Getting a different currency pair
  • EO Token
    • The EO Token
    • Ecosystem Participants
    • EO Token Utility
    • EO Token Flywheel
    • Security and Enforcement
    • A New Chapter in Oracle Design
  • Understand eOracle
    • eOracle Trust Model
    • Architecture Overview
    • Data Processing
    • Security
      • Cryptoeconomic Security
      • Aegis - Validator Set Configuration
  • Operators
    • Installation
    • Registration
    • Running the Client
    • Monitoring
  • 🔍Concepts
    • EigenLayer
    • Data Validators
    • Chain Validators
    • eBFT
    • OVS
    • eOracle Chain
Powered by GitBook
On this page
  • Prerequisites
  • Edit/Deploy using Remix by clicking here.
  • The code has the following elements:
Export as PDF
  1. ePRICE

Integration Guide

PreviousIntroduction to ePRICENextRisk Management and Market Integrity

Last updated 3 months ago

Price feeds are a crucial component in the decentralized finance (DeFi) ecosystem, allowing for a wide range of financial activities such as lending, borrowing, trading, and derivatives. Price feeds enable dapps to access accurate and updated pricing data in a secure and trustless manner.

eOracle price feeds aggregate information from many different data source and are published on-chain for easy consumption by dApps. This guide shows you how to read and use eOracle price feeds using Solidity.

Reading eOracle price feeds on EVM-compatible blockchains follows a consistent format for both queries and responses across different chains.

eOracle follows Chainlink's , allowing a smooth transition between oracle providers.

Prerequisites

  • You have a basic understanding of .

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

interface IEOFeedAdapter {
    function decimals() external view returns (uint8);
    function description() external view returns (string memory);
    function version() external view returns (uint256);
    function getRoundData(uint80 _roundId)
        external
        view
        returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

    function latestRoundData()
        external
        view
        returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}

contract EOCLConsumerExample {
    IEOFeedAdapter public _feedAdapter;
    /**
     * Network: Holesky
     * EOFeedAdapter: 0xDD8387185C9e0a173702fc4a3285FA576141A9cd
     * Feed Symbol: BTC
     */

    constructor() {
        _feedAdapter = IEOFeedAdapter(0xDD8387185C9e0a173702fc4a3285FA576141A9cd);
    }

    function getPrice() external view returns (int256 answer) {
        (, answer,,,) = _feedAdapter.latestRoundData();
    }

    function usePrice() external {
        int256 answer = this.getPrice();
        // Do something
        // .............
    }
}

The code has the following elements:

  • An interface named IEOFeedAdapter defines several functions for accessing data from an external source.

  • These functions include retrieving the decimals, description, and version of the data feed, as well as fetching round data and the latest round data.

  • The constructor initializes a public variable named _feedAdapter, which is of type IEOFeedAdapter. It sets _feedAdapter to connect to a specific EOFeedAdapter contract deployed on the Holesky network at address 0xDD8387185C9e0a173702fc4a3285FA576141A9cd. This adapter is designated for the BTC feed.

  • The getPrice() function retrieves the latest price data from the _feedAdapter by calling the latestRoundData() function. It returns the answer, which represents the latest price of the BTC feed.

  • The usePrice() function internally calls getPrice() to fetch the latest price , illustrating how the price could be parsed and used.

Edit/Deploy using Remix by clicking .

Contact for more details on deployments and usage.

AggregatorV3Interface
smart contract development
here
support@eoracle.io