Releasing Stuck Ethereum Transactions

Ethereum is experiencing a backlog of transactions at current, resulting in a number of transactions not being processed for hours or even days. This article explains how transactions can become stuck, and what can be done to release them.

Deciding on gas price

There are many methods for deciding on the best gas price when sending an Ethereum transaction. Websites such as https://ethgasstation.info/ provide an overview of the gas usage and information about the current transaction pool can be found at https://www.etherscan.io/txsPending

The latter website is especially useful because it can order transactions by gas price. To do so click on the GasPrice column. The resultant list is roughly how miners will look at the transactions so if you select a gas price value to ensure that your transaction is in the first couple of pages you are likely to have very short confirmation times.

But what if your transaction has not been confirmed? It is possible that it has become stuck, and needs action to be released.

Understanding stuck transactions

Before explaining how to release stuck transactions it is important to understand why transactions become stuck in the first place. Ethereum is a blockchain: multiple blocks, each containing transactions and linked one after the other in a chain as shown below:

Simplified view of Ethereum’s blockchain

(In reality both individual blocks and the chain structure are more complex, but the diagram provides a sufficient overview for the purpose of this article).

The concept of blocks being created by miners through a process called mining is well-known, but the process by which transactions are selected for a particular block is less clear. To explore this process in more detail, let us look at the creation of example block 1434 below.

Ethereum contains many elements other than the blockchain, and one of these is the transaction pool. The transaction pool contains all of the transactions that have been submitted to the Ethereum network but have not been allocated to a block.

At the point that block 1433 has been mined, the mining of block 1434 begins. Block 1434 starts empty:

Initial miner state for block 1434

The miner will select a number of transactions from the transaction pool to insert in to block 1434 and start the mining process:

Populating the block prior to mining

Once block 1434 has been mined successfully it forms part of the blockchain and the relevant transactions are removed from the transaction pool:

Block 1434 mined: mined transactions removed from the transaction pool

(Again, this is a much-simplified explanation of what really goes on).

The obvious question is “how do miners select which transactions to put in to their block?”, to which the answer is: “money”.

Every transaction submitted to Ethereum has a number attached to it that represents the amount of funds that the submitter is willing to pay the miner to include the transaction in their block, known as the gas price. When a miner examines the transaction pool and sees two otherwise identical transactions it will pick the one with the higher gas price, as that will result in more money being paid to the miner when the block is mined.

(Another simplification; the total amount of money that the submitter pays the miner is in fact the gas price multiplied by gas used. In turn, gas used is dependent on the complexity of the contract being called by the transaction. The important point to remember, though, is that higher gas price transactions are more attractive to miners).

When there are more transactions in the pool than fit in the next block this means that those transactions with lower gas prices will be left out of the block. And if the number of higher gas price transactions entering the pool meets or exceeds the capacity of each block then ones with low gas prices might never be picked. At this point the low gas price transaction is stuck.

Dealing with stuck transactions

Transactions can become unstuck by themselves if the number of transactions being submitted to Ethereum drops, but otherwise manual intervention is required to release them.

Releasing a transaction requires increasing the gas price for the transaction to a higher value such that it will be higher up the list when the miner selects transactions for a block. To do this the transaction must be rebroadcast with a higher gas price. For example, here is a transaction that is stuck due to a low gas price:

Type:                   Pending transaction
From: 0xED96dD3Be847b387217EF9DE5B20D8392A6cdf40
To: 0xa34C6BCAe6F46ac6470443CCea67d937f6060c7E
Nonce: 1
Gas limit: 21000
Gas price: 1 GWei
Value: 0.005 Ether

Note that the gas price shows as 1 GWei. Resubmitting the transaction with a higher gas price (here 10 GWei) overwrites the prior transaction:

Type:                   Pending transaction
From: 0xED96dD3Be847b387217EF9DE5B20D8392A6cdf40
To: 0xa34C6BCAe6F46ac6470443CCea67d937f6060c7E
Nonce: 1
Gas limit: 21000
Gas price: 10 GWei
Value: 0.005 Ether

Note that the “From” address and the “Nonce” are the same in both transactions. These two values identify the transaction, and allow it to be overwritten. Also, the gas price has changed accordingly.

Alternatively, the transaction might need to be cancelled. Ethereum has no mechanism to remove a transaction from the transaction pool but it is possible to overwrite the transaction with different information, for example a 0-value transfer back to the sender, that has a similar effect. However, this is still a transaction and will still need to be mined. Resubmitting the above transaction with a cancellation results in the following:

Type:                   Pending transaction
From: 0xED96dD3Be847b387217EF9DE5B20D8392A6cdf40
To: 0xED96dD3Be847b387217EF9DE5B20D8392A6cdf40
Nonce: 1
Gas limit: 21000
Gas price: 60 GWei
Value: 0

Note that the “To” address has changed to the same as the “From” address and the “Value” is now 0.

Whenever a transaction is replaced the new gas price must be more than 10% higher than the previous price to be accepted, so an attempt to change a gas price from 20GWei to 21GWei will not succeed and the original transaction will remain in the transaction pool.

Using Ethereal to release stuck transactions

Ethereal is a command-line tool that allows you to carry out common Ethereum activities using standard Geth or Parity keystores. Ethereal contains commands to release stuck transactions with ease.

To install Ethereal you will need to have Go installed. To check if you have Go installed type:

go version

If Go is installed you will see a version report, for example:

go version go1.8.1 linux/amd64

If Go is not installed, you can install it using your computer’s package manager or by following the instructions at https://golang.org/doc/install

Once Go is installed, install Ethereal with the following command:

go get -u github.com/wealdtech/ethereal

Confirm that Ethereal is available and the account which sent the stuck transaction is visible by running:

ethereal account list

and ensuring that your required account is in the list.

To check the status of a transaction run ethereal transaction info , for example to find out the status of the original stuck transaction listed in the previous section:

ethereal transaction info --transaction=0xec08e7609d80f233fd92cc41068ea0dd6da5d9c05263d45b0a5eee6e20f96194

To increase the gas price for a transaction without altering the other parameters run ethereal transaction up with an altered gasprice value, for example to increase the gas price to 10 Gwei :

ethereal transaction up --transaction=0xec08e7609d80f233fd92cc41068ea0dd6da5d9c05263d45b0a5eee6e20f96194 --gasprice=10gwei --passphrase=secret

where passphrase is the phrase that unlocks the account that sent the stuck transaction.

To cancel a pending transaction run ethereal transaction cancel with an altered gasprice value:

ethereal transaction cancel --transaction=0xc04116457f8f420bb13d770ffbb233501f193ba7c57cd1e4bc2ec02804a8df6a --gasprice=60gwei --passphrase=secret

Use of Ethereal can provide you with the ability to release stuck transactions and ensure that transactions go through in time even when the Ethereum network is busy.