Does eth_getTransactionReceipt respond to re-orged transactions?

Hi, new Ethereum/Polygon developer here. I am trying to send transactions and make sure they didn’t get lost in an orphan block. (Trying my best to use correct terminology but correct me when i am wrong please :slight_smile: )

So for example if i send a transaction and it fails after 5 confirmations as a longer chain is selected, do I still get a valid response on eth_getTransactionReceipt? Or is there a better way to track failed valid transactions? Thanks for the help!

4 Likes

Hi @Ptarmigan, welcome to Consensys forums!

This turns out to be a big question (for me).

You will get a tx receipt back but, as you note, there is a small chance of a reorg. In a re-org the shorter side chain (one block usually, two occasionally) will have all its tx’s reverted and placed back in the mempool. Calling eth_getTransactionReceipt at this point will return null, until the tx is added to a new block and validated.

So, this suggests you need to save the tx hash in a queue and recheck it again when a certain number of later blocks have been verified on chain. Or, perhaps, monitor for re-orgs by subscribing to “newheads” and looking for discontinuities, see here, and rechecking only the re-orged blocks.

I found this paper that might be interesting. I’ll read it but in the mean time, if anyone has any other insights into best practice for confirming sent transactions are finalised on chain, given all the things that can go wrong (low gas, dropped tx’s, re-orgs, etc), please add to this thread!

1 Like

It does, but in case there is no cofirmation of the deposit or withdrawer at the actual destinationit can viewed on etherscan and probably corrected as the case may e

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.