# Nibiru Oracle (EVM) - Usage Guide
Nibiru EVM includes a precompile for Nibiru's oracle module, providing access to exchange rate data and ChainLink-like oracle smart contracts. This allows developers to query real-time price information for various markets directly on-chain.
Section | Purpose |
---|---|
ChainLink-like Feeds - Nibiru Mainnet | Go here to find the deployed ChainLink-like oracle contract addresses. |
Using the ChainLink-like Nibiru Oracles | Start here to learn how to use ChainLike-like oracles in your Web3 app or smart contracts |
Example: TypeScript, Ethers v6, and the Oracle Precompile | To use the Nibiru EVM Oracle precompile |
Appendix | Related Pages, and ChainLink-like Feeds on Nibiru Testnet |
# ChainLink-like Feeds - Nibiru Mainnet
Smart Contract Implementation: These feeds are deployments of
NibiruOracleChainLinkLike.sol (opens new window),
a contract that sources data from the Nibiru Oracle Mechanism and exposes the
data in the ChainLink AggregatorV3Interface
format.
Reference:
Asset | Decimals, Name | Address |
---|---|---|
NIBI:USD | 6, Nibiru | 0x97412699a841fD936392C7efFd0c268eBE27a0Ec |
ETH:USD | 6, Ethereum | 0x6187b99Cad5fbF30f98A06850d301cb1b31b27b2 |
BTC:USD | 8, Bitcoin | 0x445Ca1db886ED3f08b8957e0581c25AfC6f48081 |
ETH:USD | 8, Ethereum | 0x0a713B47d49944908a983F5a42bF743b590137BE |
NIBI:USD | 8, Nibiru | 0x1ee4787898Fa3082e3af8a04e19450b17E97E70a |
USDC:USD | 8, Circle | 0x22A1eBBe1282d9E4EC64FedF71826E1faD056Eb1 |
USDT:USD | 8, Tether | 0x86C6814Aa44fA22f7B9e0FCEC6F9de6012F322f8 |
# Using the ChainLink-like Nibiru Oracles
The Oracle precompile integrates with ChainLink's AggregatorV3Interface, allowing access to decentralized price feeds.
# ChainLink-Like Nibiru Oracles in a Web3 App
To query these oracles in a Web3 application, you can import the @nibiruchain/evm-core
package on npm.
Note that in this example, we use the address for ETH. We include the list of all active ChainLink-like feeds in the "Nibiru Mainnet - ChainLink-like Feeds" section.
Example output - Oracle for ETH on mainnet
# ChainLink-Like Nibiru Oracles in Solidity
# Example: TypeScript, Ethers v6, and the Oracle Precompile
To communicate directly with the Nibiru EVM Oracle precompile, you can use the ethers.js library to interact with the contract. The script you provided already demonstrates how to query the Oracle for exchange rates and Chainlink prices using the correct contract address and ABI.
Here's a breakdown of the necessary steps to ensure a smooth communication with the precompile, along with some refinements:
# How This Script Works
- The script connects to the Nibiru EVM Oracle precompile using the predefined address and ABI.
- It queries the
queryExchangeRate
function to get the price, block time, and block height for each asset pair. - It also queries the
chainLinkLatestRoundData
function to fetch the latest ChainLink price data. - The results are logged to the console for each pair, with appropriate formatting for clarity.
# Explanation of Key Components
Provider Setup: Connects to the Nibiru Testnet via the RPC endpoint (https://evm-rpc.testnet-2.nibiru.fi/ (opens new window)) to establish communication with the Ethereum-compatible network.
ABI Definition: Specifies the functions available for interaction with the Oracle smart contracts, allowing querying of prices and exchange rates.
Supported Asset Pairs: Lists the asset pairs (e.g., "ueth:uusd", "unibi:uusd") supported by Nibiru’s Oracle system for querying price data.
Error Handling: Implements robust error management using try-catch statements to handle potential failures gracefully during queries to the Oracle or ChainLink-like feeds.
Formatted Output: Provides clear and precise price data formatted to 18 decimals, ensuring readability and ease of interpretation.
This approach directly communicates with the Nibiru Oracle precompile, and you can extend this to include other queries or add additional functionality as needed.
# Appendix
# Related Pages
- Understanding the Oracle Precompile
@nibiruchain/evm-core
package on npm@nibiruchain/solidity
package on npm
# ChainLink-like Feeds - Nibiru Testnet
Reference: Nibiru Networks and RPCs
Asset | Decimals, Name | Address |
---|---|---|
BTC:USD | 8, Bitcoin | 0x1CA6d404DB645a88aE7af276f3E2CdF64A153107 |
ETH:USD | 8, Ethereum | 0xcAF7BaB290E540f607c977a2e95182514Aeb957f |
NIBI:USD | 8, Nibiru | 0x2b6C81886001E12341b54b14731358EbAD3a83bd |
USDC:USD | 8, Circle | 0x9fc81892ea19d6d3Db770A632C8D5Dd1889DE075 |
USDT:USD | 8, Tether | 0xBC3bac25cdf3410D3f2Bd66DC4f156dB49ac92Cb |