pyth-evm

Integrate Pyth pull-oracle price feeds into EVM smart contracts and TypeScript clients.

1|1|Updated May 21, 2026
One-click install
npx skills add https://github.com/naruto11eth/cryptoskills --skill pyth-evm-naruto11eth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pyth-evm
Source: https://github.com/naruto11eth/cryptoskills/tree/main/skills/pyth-evm
Command: npx skills add https://github.com/naruto11eth/cryptoskills --skill pyth-evm-naruto11eth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents and developers frequently misintegrate Pyth oracles on EVM chains: exposing updatePriceFeeds as a standalone function (enabling sandwich attacks), hardcoding update fees, using wrong per-chain contract addresses, mishandling negative price exponents, and ignoring confidence intervals. This Skill provides correct, production-grade integration patterns for Pyth's pull-based oracle model. ## Core Features & Use Cases - Anti-Sandwich Integration Patterns: Atomic updatePriceFeeds + price read in a single transaction, with dynamic fee computation via getUpdateFee and confidence interval validation. - Hermes API & TypeScript Client: Fetch latest or historical price updates from Hermes, stream prices via SSE, and submit updates on-chain using viem. - Reference Data: Per-chain Pyth contract addresses, bytes32 feed IDs for major pairs, error code tables with fixes, and gas cost benchmarks. - Advanced Flows: Sponsored feed fallback logic, historical benchmark prices via parsePriceFeedUpdates, multi-feed batch updates, and Express Relay integration for MEV-protected liquidations. - Use Case: Build a lending protocol on Arbitrum that liquidates undercollateralized positions using fresh ETH/USD and BTC/USD prices, with confidence validation and MEV-protected liquidation routing through Express Relay. ## Quick Start Ask the agent to write a Solidity contract that consumes the Pyth ETH/USD price feed on Arbitrum using the atomic update-and-read pattern with confidence validation.

Frequently Asked Questions about pyth-evm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate Pyth price feeds into a Solidity smart contract?

Fetch price update data from the Hermes API, then call updatePriceFeeds and read the price in a single transaction using getPriceNoOlderThan. Compute the fee dynamically with getUpdateFee and pass it as msg.value. Never expose updatePriceFeeds as a standalone public function, as this enables sandwich attacks.

What is the difference between Pyth and Chainlink oracles?

Pyth uses a pull model where consumers fetch prices from the off-chain Hermes service and submit updates on-chain, while Chainlink pushes prices on-chain on a heartbeat schedule. Pyth offers sub-second latency and lower costs for high-frequency reads; Chainlink suits low-frequency monitoring without user transactions.

Why does my Pyth contract call revert with StalePrice error 0x19abf40e?

StalePrice means no recent price update exists on-chain. Pyth is a pull oracle, so you must call updatePriceFeeds with fresh Hermes data before reading. Also check that your maxAge parameter in getPriceNoOlderThan is not too strict and that cached Hermes data is not outdated.

Are Pyth price feed IDs the same on every chain?

Yes, feed IDs are bytes32 identifiers consistent across all EVM chains; for example, ETH/USD is always 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace. However, the Pyth contract address varies by chain, so verify the correct address for your target chain before deployment.

How do I handle Pyth price exponents and confidence intervals?

Pyth returns an int64 price with a negative int32 exponent, typically -8, so human-readable price equals price times 10^expo. The conf field is one standard deviation of uncertainty; reject prices where conf exceeds 1% of the price for lending protocols to avoid exploitation during volatility.

What is Pyth Express Relay and when should I use it?

Express Relay is Pyth's MEV protection layer that routes liquidation opportunities through sealed-bid auctions instead of the public mempool, sending auction proceeds to your protocol. Use it for lending protocol liquidations on supported chains like Ethereum, Arbitrum, Base, and Optimism.