1

Assume I request a transaction A from a Ethereum Node (let's say Infura for simplicity) by using getTransactionByHash shortly after the transaction was processed by the network (currentBlockNumber = A.blockNumber). After some time x I want to determine if A has reached enough confirmations (Let's say 12).

Is it enough to request the current block number and see if the difference of currentBlockNumber - A.blockNumber is greater than or equal to 12? Can the block become an uncle and thus not be included in the current head of the blockchain? If so, how do I determine if the transaction is confirmed with 12 blocks safely?

3
  • It is possible that the transaciton ends up at a different block height if there is a chain reorg. If you retrieve the most recent block, make sure getTransactionByHash returns the same block height. – Ismael Mar 18 at 5:21
  • @Ismael so I will have to request the transaction again to check the confirmations? That's what I thought – Bernd Strehl Mar 18 at 9:49
  • It is possible for a block to become an uncle and the transaction to appear in a different block. – Ismael Mar 18 at 13:32
1

Is it enough to request the current block number

Yes

Can the block become an uncle

It doesn't become an uncle. It is or it isn't. The problem is your node may or may not be following the chain that will eventually become the canonical chain.

With each block confirmation, you reduce the odds of this exponentially. So, if you are not happy with the risk at 12 confirmations, consider bumping it up to (20?) so that the concern the minuscule.

It is probabilistic, not deterministic, so the risk never goes to zero. It becomes vanishingly small over time.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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