Pyth Network Oracle Integration

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Pyth Network Oracle Integration
Medium
~2-3 business days
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1214
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823

Pyth Network Integration (Oracles)

Pyth Network — Chainlink alternative with different model: first-party data sources. Prices supplied directly by financial institutions — Jane Street, Jump Trading, Cboe. Sub-second updates (400ms latency). Dominates Solana, actively growing in EVM ecosystem via cross-chain infrastructure.

Pull vs Push Oracle Model

Chainlink (Push): operators periodically update price on-chain. Price always available in smart contract. Updates happen per time or deviation-based triggers. Gas paid by Chainlink protocol.

Pyth (Pull): prices updated off-chain constantly. For on-chain use — user includes price update in transaction. User pays gas. Gives sub-second freshness without constant on-chain transactions.

EVM Integration

Setup

npm install @pythnetwork/pyth-sdk-solidity
npm install @pythnetwork/pyth-evm-js

Smart Contract

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

contract PythConsumer {
    IPyth pyth;
    bytes32 constant ETH_USD_PRICE_ID = 
        0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace;
    
    constructor(address pythAddress) {
        pyth = IPyth(pythAddress);
    }
    
    function doSomethingWithPrice(bytes[] calldata updateData) external payable {
        // Update price (user pays fee)
        uint fee = pyth.getUpdateFee(updateData);
        pyth.updatePriceFeeds{value: fee}(updateData);
        
        // Get updated price
        PythStructs.Price memory price = pyth.getPriceNoOlderThan(
            ETH_USD_PRICE_ID,
            60  // max age in seconds
        );
        
        int256 ethPrice = price.price * int256(10 ** (18 + price.expo));
    }
}

Frontend: Getting updateData

import { PriceServiceConnection } from "@pythnetwork/pyth-evm-js";

const connection = new PriceServiceConnection("https://hermes.pyth.network");
const priceUpdateData = await connection.getLatestVaas([ETH_USD_PRICE_ID]);

// Pass in transaction
await contract.doSomethingWithPrice(priceUpdateData, { value: updateFee });

Confidence Interval

Unique to Pyth — each price includes confidence interval (conf). Standard deviation across sources.

Allows protocol to protect itself from unreliable prices.

Pyth excellent for protocols requiring high-frequency price updates (perp DEX, lending with liquidations in volatile conditions).