pyth-evm

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

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

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, mishandling negative price exponents, ignoring confidence intervals, and using wrong per-chain contract addresses. This Skill provides correct, security-hardened 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 a troubleshooting checklist. - Advanced Flows: Multi-feed batch updates, historical benchmark prices via parsePriceFeedUpdates, sponsored feed fallback, and Express Relay integration for MEV-protected liquidations. - Use Case: Build a lending protocol on Arbitrum that liquidates undercollateralized positions using fresh ETH/USD prices, with confidence validation and MEV-protected liquidation routing through Express Relay. ## Quick Start Use the pyth-evm skill to write a Solidity contract that updates and reads the ETH/USD Pyth price feed atomically on Arbitrum 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 contract?

Fetch update data from the Hermes API, call getUpdateFee to compute the fee, then call updatePriceFeeds and read the price with getPriceNoOlderThan in the same transaction. Never expose updatePriceFeeds as a standalone public function, as that enables sandwich attacks.

Pyth vs Chainlink: which oracle should I use for my DeFi protocol?

Pyth uses a pull model where consumers submit price updates on-demand, giving sub-second latency and lower costs for high-frequency reads like DEXes and perpetuals. Chainlink's push model suits low-frequency reads and continuous monitoring like stablecoin peg checks without user transactions.

Why does my Pyth transaction 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, or increase the maxAge parameter in getPriceNoOlderThan.

Are Pyth price feed IDs the same across all EVM chains?

Yes, feed IDs are bytes32 identifiers identical on every chain; ETH/USD is always 0xff61491a.... However, Pyth contract addresses vary 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 int64 price with a negative int32 exponent, typically -8, so human price equals price times 10^expo. Validate that conf divided by price stays under your threshold, such as 1% for lending, to reject unreliable prices during volatility.

What is Express Relay and when should I use it for liquidations?

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 liquidations on supported chains like Ethereum, Arbitrum, and Base.