Some users don't realise that only one transaction can be processed at a time, and if they try to send more to the blockchain, they just get queued up. The subsequent transactions will not be processed until the first has either completed or failed.
Some times users accidentally send the same transaction several times or do it on purpose thinking that their stake has not worked.
Other times, transactions can get stuck pending for several hours or days if the gas price used was set too low, and has spiked since making the transaction.
In these circumstances, it is best to forcefully cancel the transactions, otherwise, you may lose a lot of ETH on failed transaction costs.
Follow this guide to clear these stuck transactions.
You can cancel a stuck transaction by sending a 0 ETH transaction to yourself using the same nonce of the stuck transactions. The word 'nonce' is an abbreviation for 'Number only used once'.
It will cost a little gas to do this, but it is far better than having several transactions fail and losing the max gas fee for each one.
First, start by opening your wallet on Etherscan. You can do this easily by clicking the menu in MetaMask followed by View on Etherscan.
You will see your transactions listed. You may notice several that show (pending) or just one that has been pending for several hours.
Click on the transaction that you wish to cancel. If you have several to cancel, I advise you to work from the top down, newest transaction to oldest.
On the stuck transactions, you might see:
There is a Pending txn with a lower account nonce. This txn can only be executed after confirmation of the earlier Txn Hash#
Or if its the only transaction, or earliest in the queue, you will see:
It appears that this txn is taking longer than usual
Once you are looking at the transaction you wish to cancel, press the 'Click to see More' button at the bottom. This will open a new section, and you can see the Nonce of that transaction. In this example is 80.
Now in MetaMask, go to Settings > Advanced Settings
Enable Customize transaction nonce as shown below:
Now you are ready to send a 0 ETH transaction to yourself
Click the Send button
Click Transfer between my accounts
Select the same account that you are sending from
Leave it set to 0 ETH
Scroll down, and set the Custom Nonce to the same as your stuck transaction
Now check Etherscan, you should see your new transaction, and after a few seconds, it will complete and clear your stuck transaction.
You can now try to stake/withdraw again, but this time only submit it once and use Normal or Fast gas speed.
If you are cancelling several stuck transactions, simply repeat the 0 eth transaction for each nonce, starting from highest to lowest. You do not need to wait each time.