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.

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

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 sign and submit price data to Pythnet
  2. Pythnet: A dedicated blockchain that aggregates publisher data with a stake-weighted algorithm
  3. Hermes: An off-chain price service that supplies signed price update messages
  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 arguments to the Pyth contract address on Sei:

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: A small fee, paid in the native token (SEI), to submit price update data
  • 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