Skip to main content

Pyth

Overview

The Pyth network is the largest first-party financial oracle network, delivering real-time market data to over 40 blockchains securely and transparently.

The network comprises some of the world’s largest exchanges, market makers, and financial services providers; publishing proprietary price-data on-chain for aggregation and distribution to smart contract applications.

Using Pyth network

The Pyth network introduces an innovative low-latency pull oracle design, where users can pull price updates on-chain when needed, enabling everyone in the blockchain environment to access that data point.

Developers on Kava have permissionless access to any of Pyth’s 350+ price feeds for equities, ETFs, commodities, foreign exchange pairs, and cryptocurrencies.

Here is a working example of a contract that fetches the latest price of MATIC/USD on the Kava network. You have to pass Pyth's contract address for Kava mainnet/testnet and the desired price feed id to fetch the latest price.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";

contract MyFirstPythContract {
IPyth pyth;

constructor(address _pyth) {
pyth = IPyth(_pyth);
}

function fetchPrice(
bytes[] calldata pythPriceUpdate,
bytes32 priceFeed
) public payable returns (int64) {
uint updateFee = pyth.getUpdateFee(pythPriceUpdate);
pyth.updatePriceFeeds{value: updateFee}(pythPriceUpdate);

// Fetch the latest price
PythStructs.Price memory price = pyth.getPrice(priceFeed);
return price.price;
}
}

Here you can fetch the updateData from our Hermes feed, which listens to Pythnet and Wormhole for price updates; or you can use the pyth-evm-js SDK.

This package provides utilities for consuming prices from the Pyth network oracle using Solidity. Also, it contains the Pyth Interface ABI that you can use in your libraries to communicate with the Pyth contract.

We recommend following the consumer best practices when consuming Pyth data.

For more information, check out the official Pyth documentation. There are details on the various functions available for interacting with the Pyth smart contract in the API Reference section.

Pyth on Kava

The Pyth Network smart contract is available at the following address:

Additionally, click to access the Pyth price-feed IDs.

Developers and community

The Pyth network provides additional tools to developers, such as TradingView Integration, or the Gelato web3 functions.

If you have any questions or issues, contact us on the following platforms: