1

I'd like to verify programmatically that a transaction was successful - that is the Etherum network itself recognizes that for a given transaction hash, it was valid.

Using web3.eth.sendSignedTransaction returned a promise, there's two events - one 'confirmation', the other 'receipt'.

Can I rely on the 'receipt' callback to ascertain that a transaction truly occurred? Or do I have to rely on the 'confirmation' call back as well? If so - how?

Similarly, reading getTransactionReceipt it mentions that -

The receipt is not available for pending transactions and returns null.

So, if I do get a receipt then - it means the transaction is no longer 'pending' ? That is, was successful?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Daltrey Waters
  • 325
  • 2
  • 14

1 Answers1

1

_So, if I do get a receipt then - it means the transaction is no longer 'pending' ? That is, was successful?

When the receipt becomes available (or the event is handled in your case), it means that the transaction was mined into a block.

But the tx could have been reverted (if it was a tx to a smart contract that reverted it for some reason). Check the receipt field status

  • true means that the transaction was successful
  • false means it was reverted

Mind that the status is not included in pre-Byznatium (October 2017) transactions and can also be missing in some future transaction types. See more about the transaction types in this answer.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100