It finally happened, you attempted to transfer your digital assets/swap tokens on Uniswap. In the process, your transaction (tx/txs) got stuck for the first time. Welcome to the world of Decentralized-Finance (De-Fi)! Jokes aside, this may happen once in a while since smart contracts are still not perfected. They will naturally produce errors from time to time.
Maybe you have attempted to make the same tx multiple times in a row, or the Ethereum (ETH) network reached high levels of network congestion – in either case, this leads to your tx becoming stuck. You cannot resolve this issue without getting your hands dirty. In this guide, we will explain how you can cancel a pending tx in Uniswap, so be prepared since things can get a bit technical.
How to cancel a pending Uniswap transaction via MetaMask
Most users on Uniswap exclusively use one browser extension wallet, Metamask. On that account, we will describe how one can leverage Metamask’s superb gas control features to cancel a pending tx. The topics we are about to discuss may seem complicated, but there is no need to worry as all of this is incredibly straight-forward.
Enabling advanced settings in MetaMask
First, begin by clicking on the MetaMask browser extension and clicking on your profile picture located to the right. From here, click settings and select the Advanced menu. We will have to turn on two options called ‘Advanced Gas Controls’ and ‘Customize Transaction nonce.’
Finding the transaction nonce and gas price
Next, head over to Etherscan, enter the hash of the pending tx, and find its nonce and used gas fee (in GWEI).
Canceling the previous transaction
Now, we can cancel the pending tx by creating a new one. You may decide to do so because you no longer want to make the token swap or because you transferred the assets to the wrong address. We can also complete the pending tx, but in this guide, we will cover canceling it.
But how? To cancel a pending transaction on Uniswap, we need to send a new 0 ETH transaction to ourselves. This solution increases the priority of the latest tx in the queue, effectively removing the old one.
Start by opening the same MetaMask wallet for which you have used for the pending tx. Copy your address and click on the ‘Send’ button below. Paste the address in the recipient box and then click next to visit the tx confirmation page.
Adding the correct nonce for the new transaction
Here, you will need to set up the gas fee so that it uses more GWEI compared to the pending tx. Additionally, you must also set the nonce (located in ‘Advanced Options’) to be the same one as the pending tx. You can find all of this information on Etherscan. Once you have entered the required data, click ‘Send’. As soon as the new tx is confirmed, your previous pending tx on Uniswap will be canceled.
Now that you finally learned how to cancel stuck txs on Uniswap, your journey into De-Fi should be a lot smoother. Remember, all you have to do is send 0 ETH to your wallet with higher gas fees to increase the tx speed while using the same nonce values. This will prioritize the new tx in the queue and essentially cancel your old one.