How to cancel or replace pending transactions in MetaMask

Defihut author: Nicole Lee profile picture

Nicole Lee

Stuck MetaMask transaction? Follow this guide!

About this tutorial

This tutorial will teach you how to fix a problem that occurs from time to time when using MetaMask to transact in Ethereum - when your transaction doesn’t go through or when you need to cancel a transaction for any reason.

The amount of time needed to confirm an Ethereum transaction is affected by a number of factors - usually, the higher the gas price you pay, the faster your transaction gets mined and approved. If you pay a low gas price, transactions with a higher gas price are prioritized because obviously, there’s more in it for miners. Another factor that affects the time for an Ethereum transaction to complete is how many transactions are being submitted to be approved at the same time. If the Ethereum network is congested, it will take a while for miners to work through the backlog until they reach your spot in the queue.

Every transaction sent to the Ethereum blockchain has a fee added to it. This fee is called gas. When you submit a transaction, you choose the gas price to be paid (cost of each unit of gas) and the maximum total amount of gas you’re willing to pay (gas limit). Once submitted to the blockchain, your transaction joins the queue of pending transactions. Ethereum miners select transactions from this pool to be grouped into a block of transactions to be processed.

If your transaction gets stuck, all transactions that you submit after it will be delayed. Ethereum transactions have what is called a nonce value to help identify each transaction submitted by your account. Nonces start at 0 on your account and increase by 1 for each confirmed transaction, which prevents double spending and reduces the number of problems that can come about from that.

Speeding up or cancelling a transaction is done largely the same way - by bypassing the original transaction with another transaction that has a higher gas fee but the same nonce. The higher gas fee transaction will likely go through first and the original transaction will be rejected as it has the same nonce value as the approved transaction. To cancel a transaction, you send another transaction through with the same nonce as the original transaction, but with a higher gas fee and with 0.00 ETH as the value.

Tutorial

MetaMask interface method

MetaMask makes it easy to speed up and cancel cryptocurrency transactions by including a prompt to do so when a transaction has been pending for some time. The feature is built into their interface and easily accessible with a few clicks.

Step 1: Open the MetaMask extension - your transactions will be visible in the transactions queue underneath your account details and the deposit and send buttons

Step 2: Click the three dots next to your account name and select “Expand View”

Step 3: Click your transaction to expand its details

Step 4: If your transaction has been pending for some time, you will have the option to either speed up or cancel your transaction in a series of buttons next to “Details”

Step 5: Select “Speed Up” to resubmit your transaction with a higher gas fee, or select “Cancel” to cancel your transaction

Step 6: If you selected “Speed Up”, MetaMask will ask you to adjust the transaction’s gas fee - using ETH Gas Station, set the GWEI to be either equal to or higher than the Safe Low volume

Step 7: If you selected “Cancel”, MetaMask will ask you to confirm the transaction cancellation - a fixed cancellation fee that is lower than your original transaction gas fee will be charged after the cancellation is processed

Manual method

This method still uses the MetaMask extension, but it manually overwrites the original pending transaction. The new transaction is processed and the original transaction is cancelled due to the duplicated nonce - some cost is paid through the gas fee.

Step 1: Open the MetaMask extension - this time, hover over your account name at the top of the window and click on it to copy your Ethereum wallet address

Step 2: Find your transaction using Etherscan by entering your wallet address in the search box

Step 3: Find your transaction hash - it should be pending and the Ethereum amount should match the sent transaction

Step 4: Click on the pending transaction to find the nonce labeled “Nonce & {Position}”

Step 5: Go back to MetaMask and click on the menu icon in the top left corner and select the token to be sent

Step 6: On the main page, click “Send”

Step 7: Enter or paste your Ethereum wallet address in the “To” field

Step 8: Enter the amount of token to be sent in the “Amount” field - enter the same amount as the original transaction if you’re looking to speed up your transaction, and enter 0.00 ETH if you’re looking to cancel your original transaction

Step 9: Remember to adjust the gas price and gas limit to be slightly higher than your original transaction, that way there is a chance that miners will prioritize your replacement transaction

Step 10: Type your nonce number from Step 4 into the “Nonce” field - this is important so the network will think the new transaction is the same as the old one

Step 11: Select “Next” to proceed, check the transaction details for any issues and click “Confirm” to send the transaction

Step 12: Verify the new transaction with Etherscan - the original transaction should be replaced by the new one

Note that your original transaction has to be pending for these measures to work, and even then there is still a possibility that your original transaction has already been included in a miner’s block. A completed transaction cannot be revoked. It will also be likely that you still have to pay the gas fees for the original transaction.

Thanks for reading!

We’d love to hear if you have any thoughts about this article. Let us know what you think in the comments below, or follow us on Twitter. We also have an exciting weekly newsletter with jobs, news and articles delivered directly to your inbox.

Subscribe to our newsletter

The latest jobs, news, and articles sent to your inbox weekly.

© 2020 Defihut.com - All rights reserved.