Building Real-Time Price Feeds on Kaia
In July 2024, Kaia announced its integration with the Pyth Network. This means Kaia developers can now access Pyth price feeds in their applications, avoiding the need to build a custom oracle integration from scratch.
The Kaia Docs provide a complete tutorial on implementation: How to Fetch Real-Time Prices on Kaia Using Pyth.
This article covers the conceptual foundation: what "pull" architecture means, how it differs from traditional oracle models, and which components you'll need to integrate.
The Shift: From "Push" to "Pull" Oracles
Traditional oracle architectures rely on push-based updates. Prices are written on-chain according to a fixed schedule or when certain thresholds trigger an update. This approach functions adequately in stable conditions but reveals limitations during market volatility. You may incur costs for updates your application never uses, or worse, work with stale data when prices move rapidly.
Pyth operates on a pull model. Your application retrieves fresh price data only when needed, then includes that update in the transaction.
Why This Matters for Kaia Developers
Execution-time accuracy
The price updates immediately before your contract executes, providing the precision required for trading operations and liquidations.
Usage-based costs
Gas fees apply only when you submit an update, not on a fixed schedule regardless of usage.
Low-latency design
Pyth price updates are available at roughly 400ms intervals (per Kaia documentation), which supports latency-sensitive use cases.
Architecture: How It Works
The setup has two parts: an on-chain consumer contract and an off-chain client that fetches updates.
On-chain contract (Solidity)You deploy a PriceConsumer contract on the Kaia network. The tutorial uses the Kairos testnet for demonstration. Your contract forwards the update payload to the Pyth contract, then reads the current price. The example implementation uses the USD/IDR feed.
Off-chain client (Hermes)Since this architecture is pull-based, an off-chain process must retrieve the latest price data. A script communicates with the Hermes web service to fetch update data, submits an on-chain transaction to the Pyth contract, then reads the updated price.
Getting Started
For detailed instructions including commands, configuration, and complete code, see the Kaia Docs tutorial: How to Fetch Real-Time Prices on Kaia Using Pyth.
The tutorial includes:
- Complete code snippets for the PriceConsumer contract
- Hardhat configuration guidance, including secure credential management
- TypeScript interaction scripts for fetching updates and reading prices
For contract addresses, feed identifiers, and additional tooling information, consult the Pyth Network Overview reference documentation.