When you submit a transaction on the blockchain, you pay a gas fee usually in the blockchain’s native token.
This fee tends to automatically adjust itself based on market conditions — i.e. the demand for blockspace on the blockchain itself — but it can also be adjusted manually if the transaction is stuck for a long time by bidding to the network to process your transaction sooner.
In this article, we’ll explain how to:
- Speed up a stuck transaction that’s pending for a long time, or
- Completely cancel a transaction
How to speed up a blockchain transaction with MetaMask
After sending a transaction on MetaMask, a new transaction gets added to the queue. You will see two buttons once it is added to the queue — Speed Up and Cancel.
Before clicking on the Speed Up button, click on the transaction and view the transaction details on the blockchain explorer.
Notice that the Estimated Confirmation Duration will show you how long it approximately takes for the transaction to confirm on the blockchain.
Usually, if the transaction is sent with market fees, it will settle quickly. However, if this takes too long because network utilization suddenly spiked, then you might want to speed it up if you need.
By clicking the Speed Up button, it will let you re-submit the same transaction, but with a higher gas fee that should allow the transaction to be processed faster.
You’d want to send in a transaction with a gas fee that allows it to be processed within the next several blocks. To do this, use a service like Blocknative’s gas estimator.
Blocknative gas estimator allows you to see the recommended priority fee and max fee settings (with our without EIP 1559) with the probability to get the transaction processed within the next block (i.e. 15 seconds).
For more details, you can also check out their heatmap on the same page to show average gas prices for certain times of the day.
Be sure to check these resources out before you send in a higher priority transaction to avoid overpaying for gas fees.
How to cancel a transaction with MetaMask
The simplest way to cancel the transaction is to select Cancel instead of Speed Up in the transaction window above.
However, a transaction cancellation can only be done if the transaction is still pending on the network. If the transaction is already confirmed by the blockchain, it is irreversible.
The more advanced way to cancel a transaction is to use a custom nonce.
Head over to the Advanced settings of MetaMask and enable Customize transaction nonce.
Furthermore, enable Advanced gas controls to configure and override default gas settings.
Once the two options are turned on, send a new transaction. In our example, we are going to send a zero ETH transaction to ourselves.
Paste your existing public address in the search box.
Enter 0 ETH.
Look up the pending transaction on the blockchain on your account and identify two things:
- The nonce of the transaction (here it is 73)
- The gas fee and max priority fee (here it is 60 and 1.5)
Input the Custom Nonce field with the same nonce of the pending transaction.
Adjust the gas by clicking on the Market button.
Select Advanced, making sure to use a gas fee higher than your previous transaction.
Click Save, then click Confirm to send the transaction.
These steps allows for the blockchain to pick up your cancellation request faster than your original pending transaction because of the higher gas.
Generally, for these transactions to be successful, it’s best to set the Max Fee at least 25% to 30% higher than the transaction you are cancelling.