Smart Contract Integration
Integrating ORCAFI is designed to be plug-and-play compatible with standard Solidity patterns. Currently, we support BNB Chain (Mainnet and Testnet).
1. The Consumer Interface
To consume price data, your contract should reference the IOrcafiRouter interface. This provides a standardized way to fetch the latest round data.
2. System Architecture
The on-chain system consists of three core contracts working in tandem:
- SourceRegistry: Manages approved data sources. Tracks metadata including Source Type (CEX/DEX), Reliability Score, and Active Status.
- Aggregator: Validates submissions, enforces time-checks, and prevents replay attacks.
- RiskOracle: The final output contract that consumers interact with. Stores price, confidence score, and risk classification.
3. Example Implementation
Below is a production-ready example of a user contract securely fetching the ETH/USD price.
4. Advanced Patterns
Gas Optimization
The getLatestPrice function is a view function and costs 0 gas when called externally. However, when called inside a state-changing transaction, it costs approximately 4,500 gas reading from storage.
Handling Decimals
All price feeds return values with 18 decimals standard (Wad), regardless of the asset's underlying decimals. This simplifies arithmetic operations in Solidity.
1 ETH = 3,000.00 USD ➔ 3000 * 10^185. Address Registry (Mainnet)
Use the following Router addresses for your deployments. These proxies are persistent and upgradable.
| Network | Router Address |
|---|---|
| BNB Chain (Mainnet) | 0x... (Pending Audit) |
| BNB Chain (Testnet) | 0x... (Deployment Pending) |
