This error usually means the gas price on your transaction is too low — either below what the network currently requires, or below what's needed to replace an existing pending transaction. Here's how to diagnose and fix it.
1. Replacing a Pending Transaction (Most Common Cause)
If you're resubmitting a transaction with the same nonce (e.g., to speed up or cancel a stuck transaction), most clients require the new gas price to be meaningfully higher than the original — typically at least 10% higher for both maxFeePerGas and maxPriorityFeePerGas. Submitting the same or only marginally higher gas price will be rejected as "underpriced."
Fix: When replacing a transaction, bump the gas price by at least 10–15% over the original.
2. Fetch Gas Price from the Polygon Gas Station (Don't Hardcode It)
Instead of hardcoding a gas price, use the Polygon Gas Station API for real-time recommendations. It queries eth_feeHistory over the last 15 blocks and returns the 10th, 25th, and 50th percentile priority fees as the safeLow, standard, and fast tiers.
Mainnet: https://gasstation.polygon.technology/v2
Amoy Testnet: https://gasstation.polygon.technology/amoy
{
"safeLow": { "maxPriorityFee": 30, "maxFee": 30.000000131 },
"standard": { "maxPriorityFee": 30, "maxFee": 30.000000131 },
"fast": { "maxPriorityFee": 30, "maxFee": 30.000000131 },
"estimatedBaseFee": 1.31e-7,
"blockNumber": 60123456
}
Tip: Base fee can shift between when you fetch it and when your transaction is mined. Add a 10–20% buffer to the fetched values, especially during network congestion.
3. Estimate Gas Limit — Don't Hardcode It Either
// ethers.js
const gasLimit = await provider.estimateGas({ from, to, data });
// web3.js
const gasLimit = await web3.eth.estimateGas({ from, to, data });
Add a small buffer (e.g., +20%) on top of the estimate, since estimates can be slightly off depending on execution path.
4. Nonce Management
Nonces must be strictly sequential per account with no gaps or duplicates. If you manage nonces manually (e.g., for concurrent transactions), verify your tracker reflects the correct next nonce — mismatches here often surface as transaction failures alongside underpriced errors.
5. Consider a Private RPC Provider
Private RPC providers (e.g., Alchemy, Infura) generally offer more consistent performance than public endpoints, reducing dropped transactions or inconsistent gas estimates under load. See our RPC Endpoints documentation for available options — we don't recommend any single provider.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article