Skip to main content
Pyth Network is a first-party oracle that delivers high-fidelity, low-latency financial market data on-chain. Unlike traditional push-based oracles, Pyth uses a “pull” model: applications get signed price updates on demand. This significantly reduces gas costs and still keeps the data fresh. Pyth has more than 400 price feeds across cryptocurrencies, equities, FX, and commodities. It aggregates data directly from more than 120 institutional data publishers, including major exchanges and trading firms.
Send a Pyth API key with every request to Hermes. On Sei Mainnet, use the new Pyth contract address. Pyth made both changes in its Pyth Core upgrade on August 26, 2026. This guide includes them. For background, see Pyth’s upgrade guide.

What you’ll be doing in this guide

This tutorial shows you how to:
  1. Integrate Pyth Network’s pull-based oracle system into your Sei EVM application
  2. Fetch real-time price data for the SEI token with Pyth’s JavaScript SDK
  3. Create a smart contract that consumes Pyth price feeds with proper price update mechanisms
  4. Understand Pyth’s on-demand architecture and implement efficient price fetching strategies
By the end of this guide, you will have a working demo. It can fetch and use SEI price data from Pyth Network’s oracle system, with proper on-chain verification.

Prerequisites

Before you start this tutorial, make sure that you have:

Technical requirements

  • Solidity knowledge: A basic understanding of smart contract development in Solidity
  • JavaScript and Node.js: To fetch price data off-chain with the Pyth EVM SDK
  • Development environment: Remix IDE, Hardhat, Foundry, or a similar Solidity development setup
  • Sei network access: An RPC endpoint and familiarity with the Sei EVM environment
  • Pyth API key: Hermes rejects requests without one. Pyth’s upgrade guide explains how to get a key.

Required dependencies

  • Pyth EVM JavaScript SDK (@pythnetwork/pyth-evm-js)
  • Pyth Solidity SDK (@pythnetwork/pyth-sdk-solidity)

Install

Sei network configuration

Make sure that your development environment is configured for Sei:
  • Mainnet RPC: https://evm-rpc.sei-apis.com
  • Chain ID: 1329 (Sei Mainnet)
  • Testnet RPC: https://evm-rpc-testnet.sei-apis.com
  • Testnet chain ID: 1328 (Sei Testnet)

Pyth architecture overview

Pyth’s pull-based oracle model consists of:
  1. Publishers: 120+ institutional data providers that publish price data to Pyth
  2. Aggregation: Pyth combines the publishers’ prices into one aggregate price with a confidence interval
  3. Hermes: An off-chain price service that supplies signed price update messages. It needs a Pyth API key.
  4. Target chains: EVM networks (such as Sei) where applications consume price data on demand
  5. Price update mechanism: Users submit price update data alongside their transactions

Steps to integrate Pyth price feeds

Step 1: Smart contract integration

Create a smart contract that integrates with Pyth’s on-chain price feeds:
You can find price feeds in the Pyth docs. Deploy the contract with Remix. Set the constructor argument to the Pyth contract address on your network: Pyth lists the current addresses on its contract addresses page. getLatestSeiPrice() reverts if the stored price is older than 60 seconds, or if no one has submitted an update yet. getSeiPrice() submits an update first, so it does not depend on earlier updates.

Step 2: JavaScript integration for price updates

Create a module that fetches price updates directly from Pyth’s Hermes API and interacts with your deployed contract:

Step 3: Complete integration example

This simple example combines all the parts:

Expected output

When you run the integration, you should see output similar to this:

Data structure details

Pyth price data includes these fields:
  • price: The asset price (scaled by expo)
  • conf: The confidence interval (the ± range around the price)
  • expo: The exponent that scales the price (for example, -6 means divide by 1,000,000)
  • publishTime: The Unix timestamp of the last price update

Fee structure

  • Update fee: You pay it in SEI when you submit price update data. Pyth governance sets the fee, and it can be zero. Always set value to the result of getUpdateFee, so that your code still works when the fee changes.
  • Variable cost: The fee depends on how many price feeds you update
  • Gas efficiency: The pull model is more gas efficient than traditional push oracles

Best practices

  1. Price freshness: Always check the age of a price before you use it in critical applications
  2. Confidence intervals: Consider the confidence interval for risk management
  3. Fee management: Monitor update fees and optimize the update frequency
  4. Error handling: Implement error handling for failed price updates

Resources