[Ethereum] How does (current block number – block number of a given transaction) gives the confirmation count

confirmationsgo-ethereumtransactions

I found a discussion here How do I get the number of confirmations on a transaction in geth or any other tool? that give the solution as:

web3.eth.blockNumber-web3.eth.getTransaction(<txhash>).blockNumber

I tried this formula and compared the value with the confirmation count returned by http://testnet.etherscan.io/api?module=account&action=txlist&address=0x4c… Both seems to match.

My question is how can this number be considered as confirmation? Is it the case of "longer it stays, bigger the confidence that it is genuine"?

Best Answer

Blockchains use a proof of x system to confirm the validity of a transaction by a random miner. The miner confirms that the source of the transaction is valid. He does so by looking at the block before the actual block and see if the transaction is valid. After the block is mined it gets confirmed by all the following miners and as long as the majority is not colluding the probability that the block is valid increases with each following mined block. Therefore the older a transaction in terms of blocknumber, the more validated it is.

Related Topic