Previous Block

Connecting blocks in the blockchain

Diagram showing the location of the previous block field inside the block header and how it connects the current block to the block below it in the blockchain.

The previous block field in the block header contains the hash of a previous block that the block builds on top of.

Each block links to a previous block, and this creates a chain of blocks. Or as it's more commonly known, a blockchain.

Example

Below are the top 5 blocks in the blockchain. If you check them out, you'll see that they each contain the hash of the block below it in their block headers.

Height Block Hash
841,107 0000000000000000000305e0dac1487c4330c500d55524a1010e4f0a467bcf45
841,106 000000000000000000005f431cd0882fbdd436db8f24d1cbcacc1e3db53e1e82
841,105 000000000000000000016e67c9f5057575e5ec0a09d6371e33a1d88bb17f0693
841,104 00000000000000000000d00b73ee6bade47648e8d86667bef3f5ebc78da1d7b1
841,103 00000000000000000002bbe446d26f8e6467903e77154b7a692d724e94962af6

You can visit every block in the blockchain by starting at the tip and following the previous blocks all the way to the bottom.

Usage

When constructing a candidate block, a miner will put the block hash of the current tip of the blockchain in the previous block field.

Diagram showing how a candidate block referencing the tip of the blockchain through the previous block field in the block header.

All miners want to extend the current longest known chain of blocks, because the longest chain is what all nodes adopt as the canonical version of the blockchain, and they can only collect the block reward if the block makes it 100 blocks deep in to the longest chain.

canonical – authorized; recognized; accepted
collinsdictionary.com

You can find the block at the current tip of the blockchain by running bitcoin-cli getbestblockhash.

All blocks must build upon an existing previous block. If you put a hash in the previous block field of a block that does not exist, the block will be invalid and will be rejected by nodes on the network.

Purpose

Why do blocks contain the hash of a previous block?

The previous block field is what connects blocks together in the blockchain.

A block hash is a unique reference for a block, and it's determined by the contents of the block. So by including a previous block's hash in the block header, you can create a reliable chain of data, where each chunk of data (i.e. block of transactions) is linked to the one before it.

Diagram showing how block hashes are used to create a chain of blocks.
The blockchain is just a chain of blocks connected by block hashes.

So if you tried to modify the contents of an older block (e.g. by replacing or removing a transaction), this will change the hash for that block, and it will no longer be part of the same chain of blocks, because the block that builds upon it will no longer be referring to it anymore.

Diagram showing how changing the contents of a block will change its hash, and will therefore break the link in the blockchain.
If you change one of the block hashes you're removing it from the chain.

So basically, this chain of block hashes is what prevents anyone from going back in time and changing the blockchain. Because if you did, nodes would ignore the modified block as it would not be a part of longest-known chain.

This is what people mean when they refer to the blockchain as being an "immutable ledger".

immutable – Something that is immutable will never change or cannot be changed.
collinsdictionary.com

Genesis Block

The genesis block is unique in that its previous block field contains all zeros. This is because it's the very first block in the blockchain, and so there is no "previous block" for it to build upon.

That's the only interesting fact I have about the previous block field in the block header.

Resources