Pyth Network: How First-Party Prices Reach Smart Contracts
Pyth Network brings market prices on-chain from the firms that trade the asset. Its pull model means apps fetch a signed price only when they need one.
On this page
Short answer
Pyth Network is a blockchain oracle that delivers financial market prices to smart contracts. Instead of copying prices from public websites, it collects them directly from the exchanges, trading firms and market makers that trade each asset, combines them into one price with a confidence interval, and serves signed updates that applications pull on demand. That design keeps prices fresh while keeping on-chain costs low.
What is Pyth Network?
Pyth Network is an oracle network that supplies live financial prices to blockchains. A smart contract cannot read a price from the outside world on its own, so it needs an oracle to bring that data on-chain. Pyth covers cryptocurrencies, equities, foreign exchange and commodities, and it is used by lending apps, trading platforms and stablecoins.
The network's key idea is first-party data. The prices come straight from the firms that trade the asset: exchanges, market makers and trading firms publish their own prices to the network. Those firms already collect precise prices as part of their daily business, so the data they publish is the same data they trade on.
Each price feed is a single asset pair, such as BTC/USD, and it carries two values: an aggregate price and a confidence interval. The interval shows how far the publishers disagree, so an application can tell how firm the price is. The network also offers a token, PYTH, which holders use to vote on network decisions.
What makes a first-party oracle different?
A first-party oracle takes prices from the source, while most older oracles take them from somewhere else. The table below shows the difference.
| Oracle style | Where prices come from | Weak point |
|---|---|---|
| First-party (Pyth) | Trading firms publish their own prices | Needs enough publishers per feed |
| Push oracle | Operators read exchanges and push updates on-chain | Pays for updates even when nobody needs them |
| API-scraping oracle | Operators copy public website prices | Public prices can lag or be thin |
| Single-source feed | One exchange or one API | One bad source corrupts the feed |
Because Pyth's publishers are the firms setting the prices, the network can update fast and cover many assets. The trade-off is that a feed is only as strong as its publisher set: a feed with few publishers is easier to distort than one with many. Check how many publishers back a feed before you trust it for large amounts.
The first-party model also changes the incentives. Publishers earn fees for the data they provide, so firms with good data have a reason to keep publishing it. That is different from a model where a small set of operators runs the whole oracle.
How does the pull model work?
Pyth uses a pull model, which means prices are not written to a blockchain on a fixed schedule. Instead, signed price updates are held off-chain and fetched only when an application needs one. This keeps costs down, because an app pays to put a price on-chain only at the moment it uses it.
The flow has five steps:
- Publishers post prices. Each data provider sends its current price and confidence interval for a feed.
- The network aggregates. The contributions are combined into one aggregate price with a confidence interval.
- Hermes serves signed updates. An off-chain service, Hermes, holds the latest signed price update for each feed.
- The app pulls the update. When a user acts, the app fetches the latest signed update and includes it in the same transaction.
- The on-chain program verifies it. The Pyth program on that chain checks the signatures and the freshness of the update before the app uses the price.
The same signed update can be used on many chains, because the price is created once and then delivered wherever it is needed. Cross-chain delivery uses messaging protocols such as Wormhole, so a feed created from Solana data can serve an app on another chain. If you are planning an oracle integration, the guide to implementing a blockchain oracle covers the steps in more detail.
What is a confidence interval and why does it matter?
A confidence interval is the range around the aggregate price that shows how much the publishers disagree. If the price is $3,000 with a confidence interval of $15, the publishers mostly agree. If the interval is $150, they disagree, and the price is less firm.
The interval matters because it tells an application how much to trust the number it just received. A lending app can refuse to act when the interval is wide, or it can demand more collateral. A trading app can widen its safety margins. Without the interval, an app would treat a shaky price and a firm price as the same thing.
Wide intervals appear when markets move fast, when trading thins out, or when a feed has few publishers. They are a signal to slow down, not a bug: the network is reporting honestly that the price is uncertain. Good integrations read the interval on every use and set a maximum width they will accept. The oracle best practices guide explains how to set those limits.
Where is Pyth used?
Pyth is used wherever a smart contract needs a fresh price to make a decision. Lending apps use it to value collateral and to decide when a loan is under water. Perpetual trading platforms use it to mark positions and to trigger liquidations. Stablecoin issuers use it to check the value of the assets backing their coins.
The network also serves tokenized real-world assets, where a contract needs the price of a stock, a commodity or a currency pair. Because the feeds cover traditional markets as well as crypto, the same oracle can price both sides of a trade. Prediction markets and options platforms use the feeds to settle outcomes.
Speed is the reason many of these apps choose Pyth. Prices update in under a second off-chain, so an app that pulls on demand gets a price close to the current market. That matters for liquidations, where a stale price can let a bad loan survive or close a good one by mistake. For a shortlist of alternatives, see the best blockchain oracles for startups.
Example (hypothetical): a lending app checks collateral with Pyth
Example (hypothetical): a lending app lets a user deposit 2 ETH as collateral and borrow $4,000 in stablecoins. The app pulls the latest Pyth update for ETH/USD, which shows a price of $3,000 with a confidence interval of $15. The collateral is worth 2 times $3,000, which is $6,000, and the loan-to-value ratio is $4,000 divided by $6,000, which is about 67 percent.
A week later the market falls. The app pulls a fresh update and the price is now $2,500 with a confidence interval of $20. The collateral is worth 2 times $2,500, which is $5,000, and the loan-to-value ratio is $4,000 divided by $5,000, which is 80 percent. The app's limit is 80 percent, so it flags the loan for liquidation.
Because the app pulls a fresh price on every action, the check uses the current market, not yesterday's number. And because the update carries a confidence interval, the app can see that $20 on a $2,500 price is a firm reading. If the interval had been $200, the app would have paused instead of acting on a shaky price.
What are the common mistakes?
The most common Pyth mistakes are trusting a feed without checking its publishers, ignoring the confidence interval, and accepting stale prices.
- Not checking the publisher set. A feed with two publishers is far weaker than one with twenty. Look at who publishes before you rely on a feed for large amounts.
- Ignoring the confidence interval. Using the price while skipping the interval throws away the network's main safety signal. Set a maximum interval width and enforce it.
- Accepting stale updates. A pull model only works if you check the update's age. Reject any update older than your limit, especially in fast markets.
- One feed for every decision. Different decisions need different safety margins. Liquidations need tighter limits than a display price.
- No fallback. If Pyth is unreachable, your app should pause or use a backup feed, not proceed with an old price.
For the broader picture of how oracles fit into a product, the explainer on what a blockchain oracle is is a good starting point.
Key takeaways
- Pyth collects prices from the firms that trade the asset, not from public websites
- Each feed carries an aggregate price plus a confidence interval that shows how firm it is
- The pull model fetches a signed price only when an app needs one, which keeps costs low
- Apps must check the interval and the update's age on every use
- A feed is only as strong as its publisher set, so check who publishes it
Frequently asked questions
How is Pyth different from Chainlink?
Chainlink is the best-known oracle network and mostly uses a push model, where node operators read prices and write updates to chains on a schedule. Pyth uses a pull model and first-party data: the trading firms publish their own prices, and apps fetch a signed update only when they need one. Some apps use both.
What assets does Pyth cover?
Pyth covers cryptocurrencies, equities, foreign exchange pairs, commodities and some indexes. The exact list changes as publishers are added, so check the feed list for the asset you need before you build. A feed that does not exist yet cannot be used, and thin feeds need extra care.
What is the PYTH token for?
PYTH is the network's governance token. Holders vote on network decisions such as fee levels and which chains the network supports. The token does not pay holders a share of oracle fees by itself, and it is not needed to use a price feed. Holding it is a governance choice, not a requirement for building.
How fresh are Pyth prices?
Off-chain, prices update in under a second for active feeds, because publishers stream their prices continuously. On-chain, the price is as fresh as the update your app pulls, so the freshness depends on when the app fetches it. Always check the update's timestamp and reject anything older than your limit.
Can Pyth prices be manipulated?
Any oracle can be attacked, and Pyth is no exception. The defences are the publisher set, the confidence interval and the pull model: many independent publishers make a fake price hard to sustain, a wide interval warns apps, and pulling on demand limits how long a bad price can sit on-chain. Apps should still cap exposure per feed.
Do I need to pay to use Pyth?
Applications pay a small fee per price update they put on-chain, which covers the cost of writing the update to the chain. Reading prices off-chain through the Hermes service is free for most uses. The exact fee depends on the chain, so check the current fee schedule for the chain you build on.