LogoLogo
  • Kaiko Knowledge Hub
  • Getting Started
    • About the Developer Hub
    • About Kaiko
    • Kaiko Examples
      • Capture alpha before major events impact the market
      • Trace stolen funds across a blockchain
      • Track asset volume on exchanges
      • Compare market depth between exchanges and regions
      • Identify high-potential assets before they're listed on CEXs
      • Generate a liquidity-based asset ranking
      • Analyze supply distribution to determine asset-risk
      • Identify wash trading and volume quality
      • Gauge market sentiment with Implied Volatility
      • Compare price slippage between exchanges
  • What's new?
    • 2025
      • May 2025
      • April 2025
      • March 2025
      • February 2025
    • 2024
      • November 2024
      • September 2024
      • July 2024
      • June 2024
      • March 2024
    • Previous updates
  • EXPLORE OUR DATA
    • Data dictionary
      • Data Feeds
        • Level 1 & Level 2 Data
          • Level 1 Aggregations
          • Level 1 Tick-level
          • Level 2 Aggregations
          • Level 2 Tick-Level
        • Reference Data
      • Analytics Solutions
        • Kaiko Fair Market Value
          • Oanda FX conversion
        • Kaiko Best Execution
        • Kaiko Derivatives Risk Indicators
        • Kaiko Portfolio Risk & Performance
      • Monitoring Solutions
        • Kaiko Blockchain Monitoring
        • Kaiko Market Explorer
        • Kaiko Market Surveyor
      • Kaiko Indices
    • Our delivery methods
  • COVERAGE
    • Spot markets - centralized
    • Spot markets - decentralized
    • Derivatives markets - centralized
    • Lending and borrowing protocols
    • Kaiko Blockchain Monitoring
    • Benchmarks
    • Instrument Explorer
    • Status
Powered by GitBook
On this page
  • Read and update manually
  • Update and read on-chain

Was this helpful?

Export as PDF
  1. EXPLORE OUR DATA
  2. Our delivery methods

The Kaiko Oracle

Last updated 7 months ago

Was this helpful?

This guide walks you through consuming our Robust Pair Prices through the Kaiko Oracle on Ethereum. Several asset pairs are publicly available, meaning you can access free hourly updates or update on-demand for a small fee. You can read more about the Kaiko Oracle .

Read and update manually

Visit . Here, you can see the latest Kaiko price updates for all pairs.

To update the price:

  1. Click "connect wallet"

  2. Once you've connected your wallet, click "Update"

  3. Authorize the payment of 0.01 ETH

  4. Wait a few seconds for the prices to be updated

Update and read on-chain

To read and update on-chain, you'll need to set up an off-chain listening event using a node provider of your choice to connect to the blockchain.

To update the price:

This example script uses Typescript, but you can produce similar results using other coding languages. Running the script requests a price update and listens until it's been updated on-chain. When the update is detected, it alerts your on-chain smart contract.

  1. Install ethers npm install ethers

  2. Send a transaction with a value of 0.01 ETH to the refreshPriceFeeds contract address 0xff2743c44f820c64c94eccfc1b497a1019541097

import { ethers } from 'ethers';

// Set up your Ethereum provider
const provider = new ethers.providers.JsonRpcProvider("<YOUR_PROVIDER_URL>");

// Initialize wallet using private key and connect it to the provider
const wallet = new ethers.Wallet("<YOUR_PRIVATE_KEY>", provider);

// Smart contract address
const contractAddress = "0xff2743c44f820c64c94eccfc1b497a1019541097";

// ABI definition of the contract's refreshPriceFeeds method
const abi = [
    "function refreshPriceFeeds() payable external"
];

// Create an instance of the contract
const contract = new ethers.Contract(contractAddress, abi, wallet);

async function refreshPriceFeeds() {
    try {
        // Define the amount of ETH to send (0.01 ETH)
        const amountToSend = ethers.utils.parseEther("0.01");

        // Call the refreshPriceFeeds function, sending 0.01 ETH
        const tx = await contract.refreshPriceFeeds({
            value: amountToSend // Send 0.01 ETH
        });

        // Wait for the transaction to be mined
        console.log("Transaction sent. Waiting for confirmation...");
        const receipt = await tx.wait();

        console.log("Transaction confirmed, receipt:", receipt);
    } catch (error) {
        console.error("Error while calling refreshPriceFeeds:", error);
    }
}

// Call the function
refreshPriceFeeds();
  1. Wait for at least one block for the price update to be reflected on-chain

Read the price on-chain:

This Solidity contract example is triggered by the refreshPriceFeeds function in the Typescript example above. When triggered, it ingests the updated prices on-chain.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IExternalContract {
    function latestUpdate() external view returns (uint256 price, uint256 decimals, uint256 updatedAt);
}

contract CallLatestUpdate {
    address public externalContractAddress = <PRICE_CONTRACT_ADDRESS>;

    // Function to call the latestUpdate() function on the external contract
    function getLatestUpdate() public view returns (uint256 price, uint256 decimals, uint256 updatedAt) {
        // Create an instance of the external contract using the interface
        IExternalContract externalContract = IExternalContract(externalContractAddress);
        
        // Call the latestUpdate() function on the external contract
        return externalContract.latestUpdate();
    }
}

Although one price update refreshes all prices on-chain, you must read each price feed individually. See the price feeds and their corresponding addresses at .

here
oracle.kaiko.com
oracle.kaiko.com

One price update request updates all Kaiko price feeds - there's no need to request them independently.

One price update request updates all Kaiko price feeds - there's no need to request them independently.