error: replacement transaction underpriced

  • Im trying to send a raw transaction using web3 to ropsten testnet and Im getting this error:

    replacement transaction underpriced

    where sometimes my tx works and sometimes I get this error.

    my tx parameters:

    const nonce = web3.eth.getTransactionCount(ethereumConfig.contract.account)
    const block = web3.eth.getBlock("latest")
    const gasLimit = block.gasLimit
    const gasPrice = web3.eth.gasPrice.toNumber() * 1.40 
    

    note I'm already adding 40% to gasPrice

    Try to increase your gas price. Please let me know the result

    I'm already increasing 40%

  • M1Reeder

    M1Reeder Correct answer

    4 years ago

    I have been running into this issue as well. The network thinks you are trying to replace an existing unmined transaction. There are two ways to avoid this:

    1. Adding a gas price %10 higher than the existing unmined transaction's gas price.
    2. Increase your nonce to one higher than the unmined transaction.

    I have also been getting this error:

    "Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!"

    In my case, I think the transaction is getting stuck in limbo somehow. It's not being mined by anyone, but it's not being removed from the pool of unmined transactions. Keep in mind that web3.eth.getTransactionCount(walletAddress) will only give you the last CONFIRMED nonce. So it won't take the unmined ones into account.

    so if I do 2. option should do: nonce = web3.eth.getTransactionCount() + 1 ?

    I'm having the same problem, not coding but in a transacction I'm trying to send in myetherwallet. I think increasing the nonce will solve it, but how do I do that if I'm sending my transaction through Metamask?

    So if I have an unmined transaction sitting around, does it ever go away? I don't want to have to mess with the nonce myself!

    Why does the network thinks the transaction is new? doesn't it compare the data and see it's different?

    Is there another way to replace the unmined transaction in Quorum, since the gas price is always 0 in Quorum.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM