Blockchain blocks are the fundamental building blocks of the distributed ledger. Each block contains a header with metadata, a Merkle tree summarizing transactions, and the transaction data itself. This structure ensures efficient organization and verification of data.
The cryptographic linking of blocks creates a tamper-evident chain, making the blockchain immutable. New blocks are added through a consensus process, with miners or validators competing to create and broadcast valid blocks to the network.
Block Structure
Components of blockchain blocks
- Block header contains metadata about the block
- Previous block hash links the current block to the preceding block in the chain
- Timestamp indicates when the block was created (Unix timestamp)
- Merkle root summarizes all transactions in the block using a hash tree
- Nonce is a random number used in the mining process to find a valid block hash (32-bit)
- Merkle tree efficiently organizes and verifies the integrity of transactions
- Leaves are hashes of individual transactions (SHA-256)
- Non-leaf nodes combine hashes of their child nodes (concatenate and hash)
- Root is the top hash representing the entire set of transactions in the block
- Transaction data includes a list of all transactions contained within the block
- Each transaction specifies sender, recipient, amount, and digital signature
- Transactions are typically stored in a serialized format (JSON, binary)
Cryptographic linking of blocks
- Each block header includes the hash of the previous block creating a chain
- Linking blocks in this manner makes the blockchain tamper-evident
- Altering any data in a block changes its hash
- Subsequent blocks' hashes will no longer match breaking the chain
- Allows easy detection and rejection of attempts to modify past blocks
- Ensures the integrity and immutability of the blockchain
Process of adding new blocks
-
Miners or validators compete to create new blocks based on the consensus mechanism
- Proof-of-Work (PoW): Miners solve a computational puzzle to find a valid block hash
- Proof-of-Stake (PoS): Validators are chosen to create blocks based on their stake
-
The selected miner or validator creates a new block containing validated transactions
-
The new block is broadcast to the entire network for verification
-
Other nodes verify the block's validity and add it to their local copy of the blockchain
-
The newly added block propagates through the network ensuring consistency across nodes
Genesis block vs subsequent blocks
- Genesis block is the first block in a blockchain with special characteristics
- Hardcoded into the blockchain software (no previous block hash)
- Often contains unique transactions or messages (coinbase transaction)
- Subsequent blocks are all blocks following the genesis block in the chain
- Each subsequent block references the previous block's hash in its header
- Contains regular transactions that have been validated by the network