Skip to main content
Pyth Network is a first-party oracle solution that provides high-fidelity, low-latency financial market data on-chain. Unlike traditional push-based oracles, Pyth uses a unique “pull” model where applications retrieve signed price updates on-demand, significantly reducing gas costs while maintaining data freshness. With over 400+ price feeds across cryptocurrencies, equities, FX, and commodities, Pyth aggregates data directly from 120+ institutional data publishers including major exchanges and trading firms.

What You’ll Be Doing in This Guide

In this tutorial, you’ll learn how to:
  1. Integrate Pyth Network’s pull-based oracle system into your Sei EVM application
  2. Fetch real-time SEI token price data using 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’ll have a working demo that can fetch and utilize Sei price data from Pyth Network’s oracle system with proper on-chain verification.

Prerequisites

Before starting this tutorial, ensure you have:

Technical Requirements

  • Solidity Knowledge: Basic understanding of Solidity smart contract development
  • JavaScript/Node.js: For off-chain price data fetching using Pyth EVM SDK
  • Development Environment: Remix IDE, Hardhat, Foundry, or similar Solidity development setup
  • Sei Network Access: RPC endpoint and familiarity with Sei’s 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 your development environment is configured for Sei:
  • Mainnet RPC: https://evm-rpc.sei-apis.com
  • Chain ID: 1329 (mainnet)
  • Testnet RPC: https://evm-rpc-testnet.sei-apis.com
  • Testnet Chain ID: 1328 (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: Dedicated blockchain that aggregates publisher data using a stake-weighted algorithm
  3. Hermes: Off-chain price service that provides signed price update messages
  4. Target Chains: EVM networks (like 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 fetch Price Feeds at docs. Deploy the contract using Remix with the constructor arguments set to the Pyth contract address on Sei:

Step 2: JavaScript Integration for Price Updates

Create a module to fetch price updates directly from Pyth’s Hermes API and interact with your deployed contract:

Step 3: Complete Integration Example

Here’s a simple usage example that puts it all together:

Expected Output

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

Data Structure Details

Pyth price data includes several important fields:
  • price: The asset price (scaled by expo)
  • conf: Confidence interval (±range around the price)
  • expo: The exponent for scaling the price (e.g., -6 means divide by 1,000,000)
  • publishTime: Unix timestamp when the price was last updated

Fee Structure

  • Update Fee: Small fee paid in native token (SEI) to submit price update data
  • Variable Cost: Fee depends on the number of price feeds being updated
  • Gas Efficiency: Pull model is more gas-efficient than traditional push oracles

Best Practices

  1. Price Freshness: Always check price age before using in critical applications
  2. Confidence Intervals: Consider the confidence interval for risk management
  3. Fee Management: Monitor update fees and optimize update frequency
  4. Error Handling: Implement robust error handling for price update failures

Resources