How to replace a Pending/Dropped transaction
Once a transaction has been mined and is included into a block in the blockchain, it cannot be canceled or replaced. Normally, with the right gas price and limit settings, Ethereum transactions are mined within a few seconds and do not spend much time in the transaction pool.
However, with the very high gas price these days, transactions could be pending for hours or days. Pending/dropped transactions are getting more common now and knowing how to replace these transactions becomes a required and useful skill.
Before we dive deeper, it is important to note that you can only do this if your transaction is still pending. If it's already through, the transaction cannot be replaced or cancelled anymore.
Replacing a Transaction
To replace an Ethereum transaction, first, make sure that the transaction is still pending. Check its transaction hash on Etherscan to see its latest status. If the transaction is still pending, look for the pending transaction’s nonce on the Transaction Details page. Refer below:
Some wallet interfaces provide you with options to set a higher gas fee than their default suggestion and change a transaction’s nonce.
Let’s use MetaMask as an example.
- Access your MetaMask extension, click on the round icon at the top right corner and click on Settings. Now, enable the Customize transaction nonce and Advance gas controls options.
- Go back to your pending transaction’s Transaction Details page on Etherscan. Make sure the status is still at Pending and take note of its nonce number. You are going to need it in the coming steps.
- Now, re-do the pending transaction (create a new transaction with exactly the same details as the pending one) BUT, change and set a higher gas price and change the nonce of this new transaction to the same nonce as the pending transaction. Not changing the nonce will create another transaction that is bound to be stuck at the same Pending status and not replacing the existing pending transaction as intended. If you are unsure of the best gas price for the replacement transaction, you can refer to Etherscan's Gas Tracker page for the recommended new Gas Price. Afterward, click Confirm to proceed.
- Once the new transaction has been successfully created, you will now see two pending transactions on your MetaMask wallet. From here, you can check the status of your new transaction on Etherscan.
- If all goes well, your original transaction should be replaced once the new transaction has been confirmed.
With all of the above kept in mind, before initiating a transaction on the Ethereum blockchain, users are advised to always check the congestion status of the network, determine the comfortable gas price needed for the transaction, and make sure there are no pending transactions from the sending address.
But what if you don't want to proceed with a transaction and you just want to cancel it instead of replacing or speeding it up? And since this article only outlines how to replace a pending transaction via MetaMask, how about through other platforms? Is it possible? We have a more detailed article that touches on these questions here.