How To “Cancel” Ethereum Pending Transactions?

Kaven Choi
Etherscan Blog
Published in
4 min readJul 13, 2018

Transaction on the Ethereum Blockchain is not as complicated as you might think. There are several things that you might need to know and be informed about to make sure that the transaction you are making will go through successfully.

1. Gas Fee

There are many examples of how to explain “Gas fee.” More commonly, “Gas Fee” also called a transaction fee, is a small incentive or fee that is paid to the block miners to include your transaction in the Ethereum Blockchain. The unit of “Gas Fee” is called Gwei and 1 Gwei is equivalent to 0.000000001 Ether.

from Giphy

The way we calculate how much gas fee to pay for a transaction is by multiplying “Gas Price” with “Gas Used.” Do not get “Gas Used” confused with “Gas Limit.” “Gas Used” is the total amount of gas used in the transaction while “Gas Limit” is the maximum number of gas the transaction is allowed to use before the transaction is failed.

From one Ethereum address to another Ethereum address, the gas needed for the transaction is exactly 21000 gas. Thus when sending it to another Ethereum address (not contract address), 21000 gas limit is enough. Using a gas price of 20 Gwei, the total gas fee paid for the particular transaction above is:

21000 gas x 20 Gwei = 420000 Gwei = 0.00042 ETH

The gas used for executing a contract is different from one contract to another. It is recommended to check the previous transactions from the contract address and to expect a little more while setting gas limit during a transaction involving a contract.

2. Network Congestion

Network congestion plays an important role in the amount of gas price users would need to pay and the speed of the transaction. Pending transactions of the Ethereum network determine how congested the network is. The more congested the network is, the higher the gas price users would need to pay to secure their transactions on the blockchain.

Miners will favor transactions that have a higher gas price thus including transactions that pay a higher gas price first before those with a lower gas price. Ethereum Gas Price Tracker is a simple tool that helps users determine the safe and recommended gas price to use while performing a transaction at the point of time. The gas price tracker also provides an estimate of the time needed for a transaction to be included in the blockchain for a given gas price.

Ethereum Gas Price Tracker

3. Nonce

A nonce is the number of the transaction of the sender’s address. Every transaction from an address is numbered sequentially, beginning with 0 for the first transaction. For example, if the nonce of a transaction is 10, it would be the 11th transaction sent from the sender’s address.

The nonce is essential to take note especially if you perform multiple transactions using the same address. The Ethereum network works in a way that the transaction with a lower nonce will be processed first before any other, thus if you have a problem with your first transaction, the remaining transaction will not be included in the blockchain until the one with the lower nonce is successfully included.

Replacing / Cancel Pending Transactions

Replacing a transaction on the blockchain is a little tricky.

A bit of context, to begin with. How miners work is that they prioritize transactions that pay a higher gas fee. When you send a transaction on Etherem, it is sent to a “pending transaction pool” and the transaction you have just sent is sitting there waiting for miners to include the transaction into the blockchain.

Miners will “pick” transactions that pay a higher gas fee leaving transactions with low gas fees at the bottom of the queue. This is where your transaction might be hanging out and in the midst of network congestion (see above) your transaction might take a while to be included since more transactions are going into the pool which pays a higher gas fee than your transaction.

Remember Nonce? (see above)

The trick to “cancel” your pending transaction is by replacing the transaction with another 0 ETH transaction with a higher gas fee sending to yourself with the same nonce as the pending transaction.

How to determine the nonce of your pending transaction? Look at Etherscan :D Look up your transaction hash (txhash) on Etherscan and find your nonce for the pending transaction below.

Some wallet interface will provide you with an advanced setting where you are able to set a higher gas fee and change the transaction Nonce.

MyCrypto

Sample from MyCrypto where you are able to set a custom Nonce before making a transaction.

With all of the above kept in mind, before initiating any transaction on the Ethereum Blockchain, users are advised to check the congestion status of the network, determine the comfortable gas price needed for the transaction, and making sure there are no pending transactions on the sending address.

--

--