How to Unstick Stuck Transactions in MetaMask

Eduardo Freitas
KogeCoin
Published in
11 min readOct 12, 2021
Photo by: All Crypto Art

If you’re a MetaMask user and have found yourself pulling your hair out with anxiety when a transaction seemingly pauses forever, this post is for you.

In this post, you’re going to learn why transactions may seemingly get stuck. And you’ll learn some tips on how to clear them from your transaction queue so you can get back to smooth sailing. If one transaction is stuck, then any transactions you submit after will be stuck too because your personal wallet has to go in chronological order.

This article is written from the perspective of the polygon network, but the same principles apply to other networks. You’ll just need to use a different network explorer e.g. etherscan, avaxscan, ftmscan, bscscan, etc.

Getting your Transaction ID

First, you need to copy the transaction ID of the stuck transaction to your clipboard. This will be handy in later steps as you will use it to search for your transaction details on the block explorer.

  1. Open your MetaMask wallet and go into the activity session. There will be a list of your recent transactions. When you find the one that is stuck, left click with your mouse anywhere inside the transaction field.

2. A window will open with the transaction details. When you click the button indicated below, the transaction ID will be copied to your clipboard.

Why is my transaction stuck?

If you think you understand why your transaction got stuck, you can skip ahead to the “Fixing Stuck Transactions” section. However, this section contains valuable information you may not already know. A transaction can be ‘stuck’ for many different reasons. It could be from low gas price, network congestion, running on empty, or software problems with MetaMask itself.

Low Gas Price

By far, the most common reason a transaction gets stuck or takes longer than usual is low gas price.

Blockchains require gas fees to process transactions and use a bidding system based on gas price to prioritize the transactions. Provide a higher gas price with your transaction? The faster your transaction will be completed compared to everyone else’s since it will get bumped up in the queue.

The gas price that you may have used two hours ago when the network was uncongested, may not be enough gas now if the network activity has increased since then. Because of the bidding system, other people may now be paying a higher gas price and the network will prioritize their transactions ahead of yours.

Since most dapps auto-suggest gas prices for you, one reason your transaction may be stuck is that the dapp suggested a gas price that was too low in an attempt to save you money.

A decentralized application (dapp) is an application built on a decentralized network that combines a smart contract and a frontend user interface. KogeFarm.io is an example of a dapp.

Before initiating a transaction the dapp you are using will provide a gas limit and suggested gas price for your transaction. The gas limit is usually spot on because this is basically hardcoded into the contract based on the complexity of the task. Sending a token? That’s easy and requires a lower gas limit. Interacting with a smart contract that is also sending data? That’s more complex and requires a higher gas limit. Gas limit is affected much less by network congestion and therefore is easier to estimate. You normally don’t have to worry about changing this value.

Gas limit and gas price

Gas price on the other hand? Recommended gas prices are constantly changing. Spend a minute watching Polygon Gas Tracker’s recommended gas price and you’ll see the value for a fast transaction change frequently.

This is where your dapp may have underestimated for you. Should they try and save you money but risk giving you a slow transaction by using a lower gas price? Or should they always use the gas price recommended for a fast or rapid transaction and risk potentially overcharging their users? At KogeFarm.io we always suggest a fast gas price consistent with the Polygon Gas Tracker’s “fast” transaction.

If the dapp opted for the prior option to save you money, you may get a slow stuck transaction. Perhaps the dapp even used the fast suggestion from the gas tracker website, but the network gas prices were spiking rapidly at the time. This may still cause your transaction to get behind many others and due to network congestion, not complete in a timely manner.

Take a look for yourself, if you go over to the Polygon Pending Transactions, you will probably see more than 100 transactions waiting to go through.

If you want to skip to the front of this line, you must set a higher gas fee than all these other transactions. This way, the miners will validate your transaction ahead of the others that are pending.

If you don’t provide a high enough gas price, there may be an eternally long line of people willing to pay more for their transaction than you. Your transaction will sit at the bottom of the queue even as new transactions come through and constantly cut in line in front of you.

So how do you know what gas price to provide to speed up your transaction and get it complete? Keep reading and we will explain that after mentioning a few other reasons for failed transactions.

Running On Empty

Another reason a transaction may get stuck or fail is from running too low on the gas supply in your wallet. Before you initiate a transaction, your wallet will check that you have enough gas to cover the costs for that specific transaction. However, if after you initiate the transaction, but before it completes, a prior transaction completes and uses all the available gas in your wallet you will get a failed transaction. You are running on empty. Do yourself a favor and stop trying to keep the absolute bare minimum amount of gas in your tank. This is like trying to drive another hundred miles AFTER the gas light in your car came on. Keep a little more gas in your wallet (on Polygon this is the MATIC token) and you’ll avoid this problem.

MetaMask Problems

Although less common, your MetaMask wallet may also be the cause of a failed transaction.

If you keep getting failing errors like the screenshot above, even after you attempt to increase the gas fee, you must contact their support team for a better investigation into your problem. Make sure and use the official support page. Scammers love looking for people who need “help.”

Fixing Stuck Transactions

We recommend trying the following suggestions in the order they are written since they progress from easy to hard and the first few will solve 98% of the problems. If the first few don’t work? Congrats, you get to read all the way to the bottom.

Speeding up a Transaction

If you’re new to the cryptocurrency world, you may not realize you can speed up transactions. Go to your transaction queue on MetaMask, click speed up, provide a higher gas price, then resubmit. This allows your transaction to get broadcasted again, with the same nonce (nonce is the fancy term for your transaction ID) and the new higher gas price that you have set. You can try increasing the gas limit as well, but increasing the gas fee is usually more important since it is what sets your place in line.

On MetaMask you click “save” after clicking “speed up” to submit the new gas price.

But what should you provide as the gas price? Feeling lazy and on a cheap network? Just double it. Be careful though, this could kill your wallet if you are on an expensive network like the Ethereum network. A better and more accurate way to know what to put into the gas price field is by checking the gas station prices. Each network typically has a gas station network that reports on gas prices needed for Standard, Fast, and Rapid transactions.

Polygon gas station: https://polygonscan.com/gastracker

Fantom gas station: https://ftmscan.com/gastracker

Ethereum gas station: https://ethgasstation.info/

BSC gas station: https://bscscan.com/gastracker

Third-party tool to see many different networks: https://cointool.app/gasPrice/

I typically choose fast or rapid. Sometimes if I’ve already tried to speed up a transaction once using “fast” or “rapid” and it still isn’t going through, I’ll set the gas price even higher to force it through.

Canceling a transaction

If you don’t want to speed up your transaction, you can cancel it.

In-app cancellation

The simplest way to cancel a transaction is by clicking Cancel, as in the screenshot below.

Canceling a transaction is still technically a transaction so it requires its own gas limit and gas price. Make sure you provide a high enough gas price for it to go through as shown in the previous section of this article.

However, this method is ONLY functional if the transaction is still pending on the network. If MetaMask displays the transaction as pending, but it’s not actually pending (as shown by Polygon Scan) then it’s time to reset MetaMask.

To find out if your transaction is still pending, access Polygon Scan (or the appropriate network scanner for the network you are on) and paste your Transaction ID into the field below. We describe how to get your transaction ID in the first section of this article.

The transaction details will be shown. Check the Status field. It will display “Pending” if your transaction didn’t succeed. Otherwise, it will show “Success”, like this one.

It takes a few minutes for Polygon Scan to show details like Pending or Success, and you may have to wait a little bit for the block explorer to process the details. But since you are reading this article, you’ve probably already waited a sufficient period of time. Time to reset MetaMask.

If you’ve already attempted to speed up the transaction AND it still says pending on the block explorer, skip over this section to the “Custom Nonce Method”

Resetting your MetaMask

This method should be done if your transaction is pending in your wallet, but is not present on the block explorer, as shown above.

An example of a pending transaction in MetaMask

If your transaction is not displayed, you may start the process of resetting your wallet.

Before resetting your wallet, you should know that your funds are still safe. This process only resets the wallet’s history and does not require you to re-enter your seed phrase. It’s similar to clearing your browsing history or cache on your internet browser.

  1. With your MetaMask wallet opened, click on the profile picture on the top right and select Settings.

2. You will see the Settings list in front of you. Click on the Advanced section. After that, click on the third option: Reset Account.

MetaMask will pop up a warning message, assuring you that the balances in your account will not change, that this process only resets the wallet’s history activity and does not require you to re-enter your seed phrase. Phew!

Click Reset.

Now that your wallet has been reset and there are no more pending transactions, you can attempt your transaction again.

Custom Nonce Method

Nonce essentially means your transaction ID. In more technical terms a nonce is an abbreviation for “number only used once,” which is a number added to an encrypted block in a blockchain. Each time you send a transaction, the nonce value increases by 1, and it can go on and on indefinitely, like a rising counter. This nonce value prevents double-spending, as the nonce will always specify the order of transactions. If you want to go deep into this subject, take a look at this article about it.

In the Custom Nonce Method, we are going to create a new transaction with the same nonce as the transaction you want to cancel. The old pending transaction will be cancelled by the network because it is impossible for 2 transactions to exist with the same nonce.

Before we start, we must enable the Customize transaction nonce. This action will allow you to manually input the transaction nonce (normally it just auto increments for you).

  1. Open your MetaMask wallet, go to Settings, and then Advanced. Scroll down until you see the Customize transaction nonce option and turn it on.

2. To find out the transaction nonce you want to cancel, go to Polygon Scan and past the Transaction ID in the search field.

3. Once you are there, scroll down the page and Click to see more. The nonce field will appear, displaying the nonce value.

Ignore the second number in grey, the first number (the one underlined in the photo above) is the one you are after. Another way to find the nonce is by clicking on the pending transaction in MetaMask, this displays the transaction details along with the nonce value. Now that you have identified the nonce value, the final step is to send a new transaction with the same nonce to kick the old transaction out of the system.

This new transaction will essentially be a dummy transaction (sending nothing important, going nowhere important), but the key here is that it uses the same nonce value. This will clear out the stuck transaction as only 1 transaction can exist with the same nonce.

4. Set up your dummy transaction by sending 0 Matic to yourself. Paste your wallet address in the first field. To make sure this new transaction will succeed, increase the gas fee to the fast or rapid price as explained previously. Click Next.

5. Then, set the value of the custom nonce field with the same nonce of the pending transaction. This is where you change manually the new transaction nonce, getting the old transaction cancelled by the network. Click Confirm.

Wait a few minutes for the transaction to be processed and go back to your wallet activity tab. Your old pending transaction should now be cancelled.

Once you’ve cleared out all stuck transactions (repeating one or more of the processes above many times if needed!) you are good to go!

Oh, and don’t forget to turn off custom nonce. It just makes it easier if MetaMask sets that value for you.

Conclusion

Now you don’t have to worry anymore when your transactions are stuck, there are several ways to fix this inconvenience as we saw here today. Again, never commit the sin of using low gas prices! Just kidding, you can use low gas prices. Just be prepared to wait.

If you have any other questions, please stop by the KogeFarm Telegram or Discord communities, where you’ll always find someone willing to help you out.

--

--

Eduardo Freitas
KogeCoin

A crypto enthusiast, dedicated to promote financial freedom and education.