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
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:
- Adding a gas price %10 higher than the existing unmined transaction's gas price.
- 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.
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?