← Protocols
Pyth Network
Oracle·EVM · Solana · Sui · Aptos · Cosmos · Multi-chain

Pyth Network

01Description

Low-latency, pull-based oracle. 500+ price feeds (crypto, equities, FX, commodities) updated sub-second on Pythnet and delivered on-demand to 70+ chains via Hermes + Wormhole.

02Best for
  • 01low-latency price feeds
  • 02perps / options / lending markets
  • 03non-EVM oracle support (Solana, Sui, Aptos, Cosmos)
  • 04on-demand pull oracle UX
  • 05equities and FX price data on-chain
03Install
  • pnpm add @pythnetwork/pyth-evm-js @pythnetwork/hermes-client
  • pnpm add @pythnetwork/pyth-sdk-solidity
04Environment variables
VariableScopeDescription
HERMES_ENDPOINTClientHermes REST/SSE endpoint. Public default `https://hermes.pyth.network`; use a private RPC provider for production reliability.
PYTH_CONTRACT_ADDRESSClientPyth contract address on the target chain (see docs.pyth.network/price-feeds/contract-addresses).
05Prompt snippet
Pyth is a pull oracle: fetch the latest signed VAA off-chain from Hermes (`HermesClient.getLatestPriceUpdates([priceId])` or `GET /v2/updates/price/latest?ids[]=<id>`), pass the resulting `updateData` (bytes[]) into your contract call, and inside your contract call `pyth.updatePriceFeeds{value: pyth.getUpdateFee(updateData)}(updateData)` then `pyth.getPriceNoOlderThan(priceId, maxAge)` from `@pythnetwork/pyth-sdk-solidity`. On the client side, use `@pythnetwork/pyth-evm-js` `EvmPriceServiceConnection` to subscribe to streaming updates and assemble the tx in one go. Always send `msg.value` for the update fee.
06Gotchas
  • Pyth is PULL-based — you must include `updateData` and `msg.value = getUpdateFee(updateData)` in every tx that reads a fresh price; forgetting either reverts.
  • Always use `getPriceNoOlderThan(id, maxAge)` (not `getPriceUnsafe`) and pick `maxAge` per market — reading stale prices is the #1 exploit pattern in pull oracles.
  • Prices come with `expo` (negative power-of-10); compute `price * 10^expo` carefully — mixing decimals between assets in the same market causes off-by-orders-of-magnitude bugs.
  • Use `confidence` interval: reject trades when `conf / price` exceeds a threshold (volatile / low-liquidity feeds).
  • Public Hermes endpoint is rate-limited and best-effort — production apps need a dedicated RPC provider and SSE fallback.
  • Each chain has a different Pyth contract address and different available feed IDs — do not reuse mainnet IDs on testnet.
  • Solana / Sui / Aptos integrations use platform-specific receiver contracts and SDKs; the EVM pattern doesn't translate directly.
07Alternatives