Blocks are the fundamental elements used in a blockchain network, for obvious reasons of course. The blockchain is exactly what it sounds like, a chain of blocks containing data. However, blocks of data can often sound vague and confusing, especially for newcomers. Let’s see exactly what is a block in a blockchain network, its anatomy, and its role in the mining process.
What Is a Blockchain?
Briefly, a blockchain is a distributed database that operates on a peer-to-peer network. This decentralized ledger records transactions and ownership of assets based on cryptography encryptions to ensure authenticity and network security. Transactions conducted on the blockchain are grouped together in “blocks” and then added chronologically to the network in a linear chain of data. Nodes/miners operate the network by validating these transactions and adding them to the distributed ledger.
Each block connects to the previous block by a cryptographic hash function. Each block contains its own hash and the hash of the previous block to form a chain. This way, the blockchain records the entire history of transactions in an immutable way to ensure transaction validity.
What Is a Block in a Blockchain?
So, what exactly are these blocks of data? You can consider a block in a blockchain like file storage. This storage includes a batch of transactions that the network has not yet validated. Once blockchain nodes validate the transactions, a miner closes the block and adds it to the blockchain via a process called mining. Then, a new block is opened for new transactions to be added and validated.
It’s important to note that considering the immutability of the blockchain, once transactions are added to a block, they cannot be reversed. In addition, once a block is written in the blockchain, it cannot be changed or altered.
Anatomy of a Block
Each blockchain has its own version of a block. For the sake of this article, we will use the Bitcoin blockchain as an example.
A Bitcoin block has a specific size limit of 1 MB. This might seem insignificant in comparison to our modern data storage standards, however, this small amount of storage can actually store around 2000 transactions.
So, what does a blockchain block include? Some elements of the blockchain block take up more space than others. Blocks in general, regardless of what blockchain, include the following elements:
- Magic Number: This number acts as an identifier for a specific blockchain. For example, the Bitcoin blockchain is identified with the value 0xD9B4BEF9, each block with this value belongs to the Bitcoin blockchain.
- Blocksize: This field sets the size limit of the amount of data a block can store. In Bitcoin, the block size limit is 1 MB.
- Transaction Counter: This represents the number of transactions stored in the block.
- Block Header: This field contains six different components that identify the block.
- Transactions: A list of all included transactions.
The block header and transaction data represent the main two components of the blockchain block referred to as the block header and the body.
Block Header
The block header is the part that miners hash repeatedly during the mining process in order to make a valid block. This way, instead of hashing the entirety of a blockchain block, only the header the hashed which is far more efficient.
Imagine having a miner hash a 1 MB block multiple times to get the winning value, this will become time-consuming and a tricky process. Using only the block headers, miners hash a fixed length of 80 bytes of verifiable information.
Here are the six elements that make up a block header:
- Version: This field indicates the version number of the Bitcoin protocol.
- hashPrevBlock: This field contains the hash of the previously mined block that the current block will follow.
- hashMerkleRoot: This contains the Merkle root which is basically the hash of all transactions combined.
- Timestamp: This signifies the time the block was created.
- Difficulty: The target difficulty determines how difficult the target hash will be to find.
- Nonce: The nonce number is the only value the miner has to alter until reaching the target hash. The miner wins by reaching the target hash and adding his block to the blockchain.
Block Mining
So, how do all of these components work together during block mining? Well, the first three components of the block header, version, hashPrevBlock, and hashMerkleRoot, are stable values.
The objective of crypto mining is to figure out the nonce value to reach the target hash set by the protocol. The first miner is to figure out the right nonce value according to the current difficulty level set. Then, the block gets a specific timestamp representing the time of its validation and its addition to the blockchain.