How can I find the confirmation information in ethers.js api? I cannot find such kind of function.
1 Answer
The concept of "confirmations" is not native to the blockchain. It's a term used typically to refer to the amount of blocks which are mined on top of the block we're interested in. So if we want to know how many "confirmations" some transaction has we first in which block it was mined in and after that calculate the amount of blocks which were mined after that on top of that block - that's the amount of confirmations.
The term is typically used by exchanges and other parties which need a certain level of certainty for their transactions. With 0 confirmations it's quite likely that a transaction still gets reverted due to the blockchain's consensus mechanism. So typically exchanges require something like 5-10 confirmations before they accept a transaction to be final.
In theory no transaction is ever 100% final and in theory every block in the blockchain may still get reverted. But in reality something like 5 confirmations makes a block already almost 100% certain.
-
thanks If I calculate the confirmation block number by myself for example I use the latest block number minus the block number of my transaction, I can get the confirmation number of blocks. But maybe my transaction has been taken out of the original block cannot be confirmed by other nodes so my original block will not include my transaction in this case do I need to: Confirmation_number=Latest_block.number-myblock.number If(Confirmation_number>5) Get my transaction from myblock to check again my transaction included– LouisCommented Mar 16, 2020 at 0:18
-
A mined block will always include the same transactions. If a block gets reverted a new block will get formed (at some point) to include the same transactions and you have to find that/those block(s) again. Commented Mar 16, 2020 at 6:29