10

Say we want to confirm that a value transaction tx has reached certain finality, which we define as waiting for 12 block confirmations. We do this to drop the probability of tx getting lost due a fork or it getting included in an uncle block.

The examples I've seen use getBlock and/or getTransaction first to make sure tx was mined in a block.

They then wait until 12 new blocks have been mined and seem to use getTransactionReceipt to check if tx is still in the blockchain.

  • Is there some functional difference in this context between using getTransaction and getTransactionReceipt to check if tx still has blockNumber? The implementations don't seem to use any of the additional data returned by getTransactionReceipt making it slightly confusing.

  • Lets say a fork happened or tx got into an orphaned block before 12 confirmations. Does this mean that getTransaction and getTransactionReceipt will return null for the transaction or how is this reflected in these calls?

1
  • Can you post your final solution? Jun 30, 2017 at 17:54

1 Answer 1

8

No, there is no difference in this case-- they are essentially equivalent. If the tx is orphaned, they should return null, but you should still check the block number because it may have been added to the new chain later than you expect, giving less probability of finality.

3
  • What about the tx getting lost in a fork? Will the methods still return null or the block number be null? Not sure if tx getting orphaned covers the fork case.
    – randomguy
    Jun 21, 2016 at 7:45
  • Could you also please elaborate on how the block number should be checked? Does this mean tx's initial block number can change between the first and last calls (after 12 blocks)? And furthermore, does this mean it's recommended to wait for additional blocks to cover the difference to reach 12 confirmations?
    – randomguy
    Jun 21, 2016 at 7:50
  • A fork and being orphaned are essentially the same, althlough a fork generally implies a much larger reorganization depth. As long as (tx.blockNumber - eth.blockNumber) > 12, you have 12 confirmations. Jun 21, 2016 at 12:36

Your Answer

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

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