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:
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.