Seeking Assistance in Retrieving Transaction Hashes for Failed Transactions Due to Out-of-Gas Errors

29 Views Asked by At

I need to identify transactions that have failed due to out-of-gas errors on the Ethereum blockchain. However, I'm encountering challenges in programmatically retrieving the transaction hashes for these failed transactions.

From my understanding, transactions that fail due to out-of-gas errors typically do not emit any logs or events, making it difficult to identify them directly. I've explored various methods, including using APIs like Etherscan, but haven't found a straightforward solution.

Is there a method or API endpoint available, either through Etherscan or any other service, that allows for the retrieval of transaction hashes specifically for transactions that failed due to out-of-gas errors?

I know data of those transactions exists for example this transaction on Etherscan was canceled because it ran out of gas: 0xda8c0b80d8e240a83c8f6b067c4656babeb13e8e0ece4fd4292aa06252f1285c https://etherscan.io/tx/0xda8c0b80d8e240a83c8f6b067c4656babeb13e8e0ece4fd4292aa06252f1285c

If such a method or endpoint doesn't exist, what alternative approaches could be used to achieve this task?

I understand that this may be a complex issue due to the nature of transaction failures, but any insights or suggestions would be greatly appreciated.

I tried Infura and Etherscan's API but I could neither get the hashes for failed transactions due to an out-of-gas-error nor transactions that failed for all/ any reason. These transactions have no logs and did not emit events, and were canceled, so the only information is available on the interface of Etherscan, but I want to download it or filter for it.

1

There are 1 best solutions below

0
nikos fotiadis On

Unless you can find an API that supports that you will have to find them on your own.

One way to do that would be to listen to every transaction on the network and track its status, then for the ones that reverted you can get the extra info that you want. Web3js subscriptions https://docs.web3js.org/guides/events_subscriptions/supported_subscriptions is one way to do that.