question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Polygon transactions are stuck/transaction underpriced error

See original GitHub issue

Ethers Version

5.6.1

Search Terms

polygon maxPriorityFeePerGas maxFeePerGas

Describe the Problem

There is a harcoded (1.5 gwei) maxPriorityFeePerGas (and maxFeePerGas) in index.ts.

This value is used in populateTransaction.

In case of Polygon, this will either result in a transaction stuck in the mempool, or in case og e.g an Alchemy endpoint, “transaction underpriced” error.

Code Snippet

signer.populateTransaction(txParams)
signer.sendTransaction(txParams)

Where txParams don't contain maxPriorityFeePerGas/maxFeePerGas, and is a type 2 transaction.
(Legacy transactions pass as they use gasPrice only)

Contract ABI

No response

Errors

processing response error (body="{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"transaction underpriced\"},\"id\":64}", error={"code":-32000}, requestBody="{\"method\":\"eth_sendRawTransaction\",\"params\":[\"0x02f873818981c98459682f0084596898e882520894c54c244200d657650087455869f1ad168537d3b387038d7ea4c6800080c080a07cb6e05c60a2cb7ffc83349bc52ade79afaf9fdb911c64d57aed421caa1ecbcfa05f30023a4d21dd2eab6ea619c8dbb4820ce40c71841baacf8e82cbde7e87602a\"],\"id\":64,\"jsonrpc\":\"2.0\"}", requestMethod="POST",

Environment

No response

Environment (Other)

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:17
  • Comments:36 (2 by maintainers)

github_iconTop GitHub Comments

50reactions
robertu7commented, Mar 21, 2022

My current workaround:

// get max fees from gas station
let maxFeePerGas = ethers.BigNumber.from(40000000000) // fallback to 40 gwei
let maxPriorityFeePerGas = ethers.BigNumber.from(40000000000) // fallback to 40 gwei
try {
    const { data } = await axios({
        method: 'get',
        url: isProd
        ? 'https://gasstation-mainnet.matic.network/v2'
        : 'https://gasstation-mumbai.matic.today/v2',
    })
    maxFeePerGas = ethers.utils.parseUnits(
        Math.ceil(data.fast.maxFee) + '',
        'gwei'
    )
    maxPriorityFeePerGas = ethers.utils.parseUnits(
        Math.ceil(data.fast.maxPriorityFee) + '',
        'gwei'
    )
} catch {
    // ignore
}

// send tx with custom gas
const tx = await contract.multicall(calldata, {
    maxFeePerGas,
    maxPriorityFeePerGas,
})
12reactions
Benjythebeecommented, Mar 21, 2022

And my current workaround:

  const feeData = await maticProvider.getFeeData()

  // Start transaction: populate the transaction
  let populatedTransaction
  try {
    populatedTransaction = await contract.populateTransaction.mint(wallet, arg, { gasPrice: feeData.gasPrice })
  } catch (e) {
    return
  }

I removed gasLimit from the options as it never worked;

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix "Replacement Transaction Underpriced" Error?
Replacement transaction underpriced simply means that the user-created transaction for overwriting their pending transactions was unable to be created due to ...
Read more >
Fix “replacement transaction underpriced” on Opensea ...
How to fix the MetaMask - RPC Error : Error : [ethjs-query] while formatting outputs from RPC '{“value”:{“code”:-32000,“message”:“replacement ...
Read more >
Transactions keep failing with replacement transaction ...
I got a stuck transaction on OpenSea so I tried resetting my wallet. It seems to have worked, everything looks as before and...
Read more >
Polygon mumbai testnet error 'transaction underpriced'
This could happen if somehow the nonce of the transaction you're trying to perform got to be the same as your last transaction's...
Read more >
web3js - error: replacement transaction underpriced
The error message implies that you're trying to replace a pending transaction. That's because the raw transaction you're trying to send has the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found