⚙️ How to Integrate QIE Oracle in Smart Contracts
Integrating QIE Oracle into your smart contract is simple and gas-efficient. The oracle contracts are read-only, meaning fetching data does not consume significant gas.
✅ Integration Steps
1. Import the Oracle Interface
Use the standard AggregatorV3Interface
, which is compatible with the QIE Oracle:
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
This interface is supported because QIE Oracle follows the Chainlink AggregatorV3 standard.
2. Instantiate the Oracle
Set the oracle contract address in your constructor or initializer:
AggregatorV3Interface public priceFeed;
constructor(address oracleAddress) {
priceFeed = AggregatorV3Interface(oracleAddress);
}
Replace
oracleAddress
with the deployed address of the specific QIE Oracle for your asset (e.g., QIE/USD).
3. Call latestRoundData()
to Get the Price
Fetch the latest price in your contract logic:
function getLatestPrice() public view returns (int256) {
(
,
int256 price,
,
,
) = priceFeed.latestRoundData();
return price;
}
This function is read-only (
view
) and consumes minimal gas when called externally or from another contract.
⚡️ Gas Efficiency
All price-fetching functions on the QIE Oracle are non-state-changing (read-only). This means:
No transaction needs to be sent
No gas is spent reading data (unless used inside a transaction)
Safe to use in frequent or lightweight calls
Last updated