1

I am running a geth full node on Rinkeby and testing ERC20 transactions. Recently I submitted two transactions and received transaction hashes for each of them, so I assumed I was good. But later on when looking at the geth log, I realized that both transactions failed because I didn't give enough gas.

Here is a gist of the transaction log snippet:

https://gist.github.com/gojun077/276e342d0c17422816d28466d40aad11

My program logic assumes that receiving a full hash for a tx submission means that the tx was good. But as you can see from the geth log, at 08:30:14 I got a full hash but 1 second later at 08:30:15 the announcement was discarded by a Peer and the EVM returns err="out of gas".

The second transaction gets a full hash at 08:30:15 but it errors out 2 seconds later at 08:30:17 and doesn't make it into the block.

I then tried to search for these tx hashes but they were nowhere to be found, both locally and on Etherscan. Is this normal behavior? Is there a way to detect "out of gas" transactions programmatically, i.e. without tailing logs?

1 Answer 1

1

If you are writing a program which wants to ensure that a transaction has fully completed and will be permanently part of the blockchain, you should wait at least 2-3 additional blocks, and confirm your transaction still exists. I think 6 blocks is pretty normal for most applications which have sensitivity to these kinds of things.

If you are trying to make sure a transaction does not run into any errors during execution, it might be best to emit an event, and have a listener check for that event to know that execution happened successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.