๐Integration Guide
We implemented smart contract interfaces to connect your infrastructure with real-world data using eOracle.
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.
If you are currently using a different Oracle solution and wish to transition, consider eOracle Adapter.
Prerequisites
The guide assumes you have a basic understanding of smart contract development.
This example contract obtains the latest BTC:USD price feed answer from the Holesky testnet.
Edit/Deploy using Remix by clicking here
The code has the following elements:
An interface for an external feed manager,
IEOFeedManager
, to retrieve price feeds.The
IEOFeedManager
interface defines two functions:getLatestPriceFeed
to fetch the latest price feed for a single symbol, andgetLatestPriceFeeds
to retrieve price feeds for multiple symbols at once.In the constructor, the contract initializes the feed manager, connecting specifically to a feed manager contract deployed on the Holesky network at address
0x723BD409703EF60d6fB9F8d986eb90099A170fd0
.The
getPrice()
function demonstrates fetching the latest price feed for a single symbol, in this case, the price ofBTC
toUSD
.The usePrice()
function exemplifies how to use the retrieved price feed data. It callsgetPrice()
internally, extracts the price value and timestamp from the returnedPriceFeed
struct, and performs further operations based on the fetched data.
Contact support@eoracle.io for more details on deployments and usage.
Last updated