How to deal with endless pending ethereum transactions

in #ethereum7 years ago (edited)

You might have recently noticed, either directly or indirectly, an increasing cat appearance on the ethereum blockchain by playing crypokitties yourself or just by suffering from slow transaction times on the ethereum block chain.

Sometimes it even happens, that transactions are not being sent at all and stay in the state of a pending transaction forever, maybe even blocking your other transactions from fulfilling. I was in the same situation and wanted to share how you can resend the transaction by modifying its gas price in a step by step guide.

What is the problem

After some research this is how I understood what is happening (feel free to correct me, if I am wrong):
Currently, the ethereum blockchain is experiencing a huge increase in transactions, especially due to the new cat situation...

Miners have to decide what transactions they might want to work on. Their potential fee is gas limit * gas price, so they understandably pick those transactions that are most profitable to them. If you have chosen a gas limit or gas price too small, it is very likely, that your transaction will not get confirmed, since there might be far more lucrative alternatives for the miners in the pool of pending transactions.

A more detailed explanation on how nodes pick their transaction can be found here.

How to fix the never ending transaction?

There are different approaches on dealing with that situation. I'll describe here how I have dealt with it, but I can't promise it will work in all situations. In my case it did work and I was able to send the transaction, even though it was stuck for more than a day.

I wanted to send 0.2 ether with ETHEREUM WALLET to another address but it was pending for an unusual long time. Checking the transaction on etherscan confirmed the pending state, so at least it was recognized as transaction but got never confirmed. The solution was to "modify" the transaction by increasing the gas price and increasing the gas limit as well, so it gets more attractive for miners to confirm it.

Step by step guide modifying a pending transaction

This solution does not require a specific wallet. To my knowledge none of them are able to cancel or change a transaction. I cannot give any guarantees that the following guide will work in your case. Try at your own risk!

So lets finally get rid of our pending transactions...

Step 1: connecting to geth

The only thing you need is access to geth, which is usually installed within your wallet.

In my case it is found under:

C:\Users\<user>\AppData\Roaming\Ethereum Wallet\binaries\Geth\unpacked

Leave your wallet - fully synced with the blockchain - open and start geth with the following command:

geth attach

This should result in a welcome message containing your ethereum wallet adress:

Step 2: Check pending transaction

To list all the pending transactions you just enter:

eth.pendingTransactions

Now its important to identify the index number of the transaction which is held under nonce. You need the index to tell geth what transaction you wish to modify for re-sending. Write down the nonce, the gas price and the gas limit.

Step 3: Unlock your account

For signing transactions its necessary to unlock your account. To do that, please use the following command and do NOT enter your password in plain text. That is dangerous, because it could be read by third party programs on your system. Just fill in your account address and leave the passphrase empty.

Geth will automatically ask for your password anyway:

personal.unlockAccount('<YOUR_ACCOUNT>')
Unlock account <YOUR_ACCOUNT>
Passphrase:
true

When unlocking was successful, geth will show you a true as result. Now you can finally modify our stuck transaction.

Step 4: Overwriting your transaction

What you usually want to do is increasing the gas price, so your modified transaction will be preferred over others and getting a better chance of being confirmed. So how to estimate a good value to make sure our transaction will be accepted this time?

While researching I found this decent website, which seems to give accurate values for the necessary gas price to get your transactions through. It analyses the last transactions and their usage of gas. Compare the values with those you used and determine the correct values.

Now you can modify your transaction with the following command:

eth.sendTransaction({
    from: '<YOUR_ACCOUNT>',
    to: '<DESTINATION_ACCOUNT>',
    value: <VALUE_TO_SEND>,
    gasPrice: <NEW_HIGHER_GAS_PRICE>,
    gasLimit: <GAS_LIMIT>,
    nonce: '<NONCE_OF_PENDING_TRANSACTION>'
});

Since I had trouble finding the correct syntax for each parameter, here a fully working example, using the data of my use-case. You can use it as template and just fill in your values. To avoid accidental sending, I recommend building the command in an editor first and then copy the final command in one line to your geth console:

eth.sendTransaction({
    from: '0x41690Bc8A905718262B5141d5bf203d85A4B175F', 
    to: '0x75414A5f8D5b9cC4CcC122270CFd2718991F607f', 
    value: web3.toWei(0.2, "ether"), 
    gasPrice: web3.toWei(25, 'gwei'), 
    gasLimit:200000, 
    nonce:'5' 
});

Explanation: The command sends a value of 0.2 ether with a gasPrice of 25 gwei with a maximum gasLimit of 200.000 from my account to the destination account. As nonce I use the number of the pending transaction, you wrote down in step 2, in my case it was the 5. Those web3.* commands are nice ways to format the values in a more readable way.

If the command was correct, it will show you the newly generated transaction ID. To check how your transaction is doing, you can open it on etherscan entering the new transaction ID. It might take a bit, until its posted there, so be patient:

As soon as the transaction is successful and your wallet is synchronized, it should update your ethereum balance. Unfortunately the Ethereum Wallet does not recognize the updated transaction in its history yet, but hopefully there will be a patch in the future to address this issue.

That´s it!

Let me know if this guide was helpful to you and feel free to leave a comment, especially when you have questions or suggestions on how to improve this guide.


Should you need a destination adress to check if your transactions are working again 😬, feel free to send a small amount to 0x41690Bc8A905718262B5141d5bf203d85A4B175F
Its greatly appreciated, thank you a lot!
Sort:  

Thanks for the post bud great content going to follow you i can learn a lot from you , You might want to have a look at as it has to do with ethereum as well.
https://steemit.com/ethereum/@ajkapss/microraiden-payment-channels-are-now-live-on-ethereum-main-network

I am glad to hear that this article gave you some insight on the situation. Thanks for following as well as for for the link. I'll check it out for sure! Still have to find my way here, since I registered just yesterday.

Thank you for this information. It should help many people during this time of growth.

Hi
I have a transaction on the net that needs gas to pass

Can you help me?

Hi
I have a transaction on the net that needs gas to pass

Hi
I have a transaction on the net that needs gas to pass

Can you help me?