Search code examples
hashcryptographyblockchainbitcoinproof-of-work

How do transactions add inside blockchain?


In a BTC block, there can be 1500 transaction records. And for these 1500 transactions. So, there are transaction after transaction inside a block. and blocks after block in a chain.

My questions are-

  1. Which of these have the hash? The individual transactions or the whole block?
  2. If the first case is true, then is the last transaction's hash taken for mining the next block?
  3. If the second case is true, then there will be two hashes- one for the last transaction of the block and another hash for the whole block. Then how does the authentication happens here?

Solution

  • Blockchain is a chain of blocks :) Every next block depends in some way on a previous block, with exception of first, genesis, block.

    It is a hash of entire block what matters. That hash uses the content of entire block in some way - it could be as simple as hash all bytes of a given block.

    As for hashes per transaction - you could do that, but that, probably, won't give you any particular benefit. When you know that entire block is correct, that means every transaction inside that block is correct as well, no need for additional hash or checksum.

    If you do design your own blockchain, nothing stops you from hashing transactions inside block one-by-one if that makes sense for your business case.