Interacting with Oracle on EVM
Overview
This tutorial demonstrates how to fetch oracle prices in an EVM Minitia environment using Cosmos queries. The integration is facilitated by the COSMOS_CONTRACT
from Initia's EVM precompiles that enable querying through a CosmWasm contract. Here, we explore the use of oracle data to obtain currency pair information and prices directly via Cosmos smart contracts.
Prerequisites
Enabling OraclesSample Contract Implementation
Through the evm-slinky-query repository, you can fetch oracle prices through a CosmWasm contract.
In this section, we'll provide an example contract and show how to deploy it so that you can call stargate query or directly implement it in your contract.
Get All Currency Pairs
Function to fetch all currency pairs available from the oracle.
Get Price
Function to fetch the price of a specific currency pair. pair_id
is in a format of {Base}/{Quote}
.
Get Prices
Function to fetch prices for multiple currency pairs.
Conclusion
This contract provides a foundation for integrating real-time oracle data into your blockchain applications, leveraging Cosmos-based oracles within an EVM context. It's suitable for financial applications requiring access to up-to-date currency prices and can be expanded or modified to fit specific requirements or additional functionalities.
Last updated