Original article : https://brainsorting.dev/posts/how-to-cancel-a-pending-ethereum-transaction-with-metamask/
Having a pending transaction can be quite annoying and usually happens when the network is heavy loaded and the fees are sky rocketing. Your transaction may have a too low gas fee and miner are just ignoring it to prefer others transaction with higher fees.
This result in you being stuck because until that transaction is resolved you cannot send any other transaction. Annoying right ?
Let's dive right in on how to fix this !
Gather all the informations we need
Prerequisite
This tutorial is about using MetaMask to cancel the pending transactions so you need to have it.
If you don't have MetaMask installed on chrome, here is the official address to do so.
Etherscan
The first step is to go on etherscan and paste the tx hash of your pending transaction. You can also paste your ethereum address and will be able to find all your pending transactions.
Find the oldest pending transaction, click on it and then click on Click to see More โ to get the Nonce number of that transaction.
All the transactions of an ethereum address have a nonce number that increment after each transaction.
Now the concept behind cancelling a pending transaction is to actually send a new transaction with the same Nonce but with a higher fees that the miner will verify and confirm. When this will be done, the previous pending transaction with the same nonce will simply be cancelled and forget by the network because only unique nonce transaction per ETH address can exists.
You should have those informations for going to the next phase :
- Your Ethereum address
- The Nonce of your blocked pending transaction
- MetaMask installed and running with your Ethereum address
How can I send my own custom transaction
The basic configuration of MetaMask doesn't allow us to use custom Nonce, but you can enable that option in the configuration.
Enabling the custom gas settings and custom nonce
-
Click on this button
-
The go into the settings
Now click on Advanced
I suggest to enable both Advanced gas controls and Customize Transaction nonce
Sending a custom transaction to fix the pending tx
-
Once that's done, quit the configuration and now click on the SEND button.
-
Paste your ETH address, and then add 10 GWEI to the transaction fee gas price to be sure you are above the network average Gas Price so this transaction won't be stuck pending as well. Always verify on Eth Gas Station and use a Gas Price above the FAST recommendation. Leave Gas Limit as it is (21000).
Click on Next when you are done.
-
In this screen you should be able to set your own custom Nonce if you enable it properly in MetaMask config as explained in the beginning of that article. Write down the Nonce of your blocked pending transaction and click on Confirm.
MetaMask will ask you to sign your transaction and how will depend on if you are using a Ledger or something else. Once you did sign it, the transaction will be sent and if you were above the FAST Gas Price recommendation from Eth Gas Station website it should be confirmed in less than a minute and your blocked pending transaction should now be cancelled.
If you had other pending transaction after that one that are still blocked after this, you will need to repeat the process for each one of them, from the oldest to the newest until you eventually cleared your whole pile of pending transactions.
How can I prevent that from happening again
Regularly keep an eye on the Eth Gas Station website to know the current average Gas Price, and don't always trust pre configured gas price from MetaMask. If you are doing a transaction that is very important, you can always Edit the Gas Price MetaMask is choosing for you and set it to fast, or even a custom one that you decide.
Top comments (0)