How to Use IFA Oracle Price Feed in EVM Contracts
This guide explains how to integrate IFA Oracle price feeds into your EVM contracts for accessing real-time stablecoin and asset price data. IFA Oracle provides decentralized price feeds specialized for stablecoins and other assets with high precision calculations.
Install IFA Price Feed Interface
IFA Oracle provides a Solidity interface package to interact with the deployed price feed contracts.
Truffle/Hardhat
If you are using Truffle or Hardhat, simply install the NPM package:
npm install ifapricefeed-interfaceFoundary
If you are using Foundry, you will need to create an NPM project if you don't already have one. From the root directory of your project, run:
npm init -y
npm install ifapricefeed-interfaceThen add the following line to your remappings.txt file:
ifapricefeed-interface/=node_modules/ifapricefeed-interfaceContract Addresses and Asset Registry
Asset Registry: Complete list of supported assets and their IDs
Contract Addresses: Deployment addresses for all networks
Write Contract Code
The code snippet below provides a general template for integrating IFA Oracle price feeds:
The code snippet above demonstrates the following key steps:
Instantiate the IIfaPriceFeed interface from the Solidity interface package using the price feeds contract address.
Select the Asset IDs for the assets you want to fetch prices for. Asset IDs are generated by hashing the asset symbol.
Call IIfaPriceFeed.getAssetInfo to read individual asset price information.
Call IIfaPriceFeed.getPairbyId to calculate exchange rates between two assets.
Handle decimal precision correctly - derived pair prices have 30 decimal places for maximum precision.
Key Concepts
Assets
An asset represents a token's price with respect to USD (e.g., CNGN/USD, BTC/USD). Each asset is identified by a unique hash of its symbol.
Pairs
A pair represents the exchange rate between two assets (e.g., CNGN/BTC). Pairs can be calculated in both forward and backward directions.
Precision
Asset prices use their native decimal precision (stored as negative values, e.g., -18 for 18 decimals)
Derived pair prices are always scaled by 10^30 for maximum precision
Function Examples
1. Get Single Asset Information
2. Get Multiple Assets Information
3. Get Single Pair Exchange Rate
4. Get Multiple Pairs (Forward Direction)
5. Get Multiple Pairs (Backward Direction)
6. Get Multiple Pairs with Custom Directions
Example of Real-World Use Cases
1. Stablecoin Swap Contract
2. Price Validation Contract
Data Structures
PriceFeed
DerviedPair
PairDirection
Error Handling
The IFA Price Feed system includes comprehensive error handling:
Best Practices
Always check asset existence before using price data
Validate price freshness by checking
lastUpdateTimeHandle the 10^30 scaling correctly for derived pairs
Use batch functions for multiple assets to save gas
Implement proper error handling for failed price lookups
Common Asset Symbols
Replace the placeholder Asset IDs (0x0000..., 0x1111..., etc.) in the examples above with actual Asset IDs from our supported assets:
CNGN- Nigerian Naira stablecoinUSDT- USD Stablecoin (by Tether)USDC- USD Stablecoin (by circle)EURC- Euro StablecoinBTC- BitcoinETH- EthereumAnd many more...
For the complete list of supported assets and their corresponding Asset IDs, see our Asset Registry.
Additional Resources
Asset Registry: Complete list of supported assets and their IDs
Contract Addresses: Deployment addresses for all networks
Interface Package:
npm install ifapricefeed-interface
Support
For technical support and integration assistance, please refer to the IFA Labs documentation or contact the development team here
Last updated

