Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pages/price-feeds/use-real-time-data/pull-integration/evm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ Then add the following line to your `remappings.txt` file:
@pythnetwork/pyth-sdk-solidity/=node_modules/@pythnetwork/pyth-sdk-solidity
```

## Why Update Prices

Pyth uses a pull-based oracle model. Unlike traditional push oracles that automatically update prices on-chain at regular intervals, Pyth requires users to explicitly update the on-chain price before reading it.

This design offers several advantages:

- **Lower costs**: You only pay for price updates when you need them
- **Lower latency**: You can fetch the latest price update directly from Pyth's low-latency oracle network and submit it on-chain immediately
- **Flexibility**: Different applications can update prices at different frequencies based on their needs

In the Pull integration pattern, your contract must:

1. Accept `priceUpdate` data from the caller (fetched from [Hermes](../../how-pyth-works/hermes))
2. Call `updatePriceFeeds()` to submit this data on-chain before reading prices
3. Pay a small fee for each update (calculated via `getUpdateFee()`)

<Callout type="warning" emoji="⚠️">
**Important**: If you don't update the price or if the on-chain price becomes
too stale, calls to `getPriceNoOlderThan()` will revert with a `StalePrice`
error (0x19abf40e). See [how to fetch price
updates](../../fetch-price-updates) for more details.
</Callout>

## Write Contract Code

The code snippet below provides a general template for what your contract code should look like:
Expand Down
Loading