Have you ever made a crypto transaction and not paid enough for the mining fee resulting in it taking ages to be mined?
I recently did exactly this whilst moving some ETH from my wallet to an exchange. It was an interesting learning opportunity so thought I’d share my experience.
My first mistake was to not take a look at https://ethgasstation.info/, this is a really useful website which gives live updates on the gas price you need to use for Ethereum transactions to be mined within a reasonable time period.
At the time I made the transaction the Ethereum network was really busy, I should have used a fee of ~18 Gwie, but I used just 3 Gwie.
After I’d submitted the transaction to the network I realised my mistake and thought it might take a day or two. 4 days later I was still waiting…
I began looking if there was a way to speed up an ethereum transaction and discovered there was, I will describe my steps below but it is first important to understand the difference between gas price and gas limit.
The price of Gas (Gas Price) is the amount of Gwei you are willing to spend on each unit of Gas. The Gas limit is how much gas you are prepared to spend on running a contract on the Ethereum Virtual Machine (EVM). The standard gas limit for a simple transaction on Ethereum should be set at 21,000 units of gas.
If you set the gas limit too low you will run out of gas before a contract executes and it will fail, if you set the gas price too low there is no incentive for miners to mine it so it may wait for a very long time. (depending on how busy the network is).
Consider this analogy; the gas price is the price per gallon of petrol you put in your car. The Gas limit is how many gallons you put in. If you set the limit to low you run out of gas before getting there.
So… What to do?
I discovered from reading more deeply that a pending transaction can be replaced by constructing another transaction with the same ‘nonce’. Ethereum transactions must be added in order so until my stuck transaction was mined I couldn’t make another.
The nonce which has been used for a transaction can be found by viewing the transaction on https://etherscan.io/. If you search your ETH address, then click on the transaction hash and scroll down until you see ‘see more’, click this and the nonce used can be found here.
The image below shows this, obviously yours won’t be 1393, it’ll be something different depending on how many transactions you have made.
I didn’t really want to risk losing / wasting money and I hadn’t tried this before so I decided to test this theory out of the Ethereum Ropston testnet. You can easily do the same to play and learn. I used a wallet called ‘My ether wallet’ which can be ran as an online wallet to create a couple of different addresses on Ropston ethereum. I then used a faucet to get some test ether. I created a transaction for 0.1 ROPETH and sent with a gas price of 1 Gwei, this transaction had a nonce of ‘1’, whilst that was pending I quickly created another transaction from that wallet for 0 ROPETH and sent to myself with a gas price of 20 Gwei, using the advanced settings I changed the nonce from ‘2’ (which the wallet chose as it was the next transaction back to ‘1’). I sent this too and looking on etherscan I could see both pending. Within 30 seconds the transaction with the 20 Gwei gas fee was mined. This sent 0 ROPETH back to my wallet replacing the previous transaction with the 1 Gwei gas price. This basically cancelled the pending transaction as the nonce used was the same.
I experimented further on Ropston testnet and tried sending to other addresses instead of back to myself. It seemed that providing the nonce used was the same as the stuck transaction, once the new one is mined the other gets cancelled. I also noted, the order doesn’t matter. As soon as a transaction is mined, any others with the same nonce are cancelled.
Once I was confident I put this into practice on the live ethereum network. I constructed another transaction from my original wallet to the exchange address for the same amount as my stuck transaction, I then clicked ‘advanced settings’ in my wallet and located the nonce which it was going to assign to this transaction, I edited this and replaced it with the nonce of my stuck transaction. This time i set my gas price to 25 Gwei and the gas limit to 21,000 as standard. I submitted it to the network and around 60 seconds later the transaction had been mined. I viewed the old stuck transaction on etherscan and it said it had been ‘dropped/replaced’.
The new transaction successfully replaced the existing one and solved the problem.
The following resources might be helpful if you want to read more;