How to cancel an Ethereum transaction that is stuck in a pending state? Miners order and process the highest gas fee transactions first on the Ethereum network. If there is a lot of volume on the network and you priced your gas amount too low your transaction might not process. You will need to wait until the network congestion clears or you fix the transaction.
In this tutorial I will explain how to fix a transaction that is pending processing in the Ethereum transaction pool. This is a very simple process that anyone can do. To start make sure you have MetaMask installed or a wallet that lets you set a nonce on a transaction.
Transaction problem on Ethereum
When viewing your transaction using a block explorer (Etherscan) you might see that it is “pending” and has not been included in a block. Transactions can be pending for hours or even days.
If a transaction is pending every transaction after it in the same account will be pending. Ethereum transactions are processed using the FIFO method (first transaction in an account is the first transaction processed in the account). To keep track of the order of transactions to process in an account Ethereum uses a nonce which is a incrementing number for each transaction. For example 1 is the first transaction in the account, 2 is the second transaction, 3 is the third, etc.
Fix the pending transaction in your account
First, find the oldest transaction that has a problem. This transaction is preventing all future transactions from processing.
Second identify the “nonce” of the transaction that is causing the problem. The nonce is the sequence number of the transaction in the account.
Third, in MetaMask click on Settings then Advanced and make sure Customize Transaction Nonce is turned on. This will allow you to assign a nonce to a transaction.
Finally send the same account a transaction with a 0 amount, HIGHER gas price, and set the nonce in the transaction to the SAME number as the problem transaction.
Setting the nonce to the same number as the transaction that was pending will result in the new transaction replacing the old transaction. This 0 transaction will cause a gas fee but your transactions will process and not be in a pending state.