Blockchain Block Anatomy
Tags: blockchain, beginners, tutorial, devjournal
Published: 2023-01-07 16:26:29


So far in this article series, we have discussed the [Blockchain](https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa), its [roadmap](https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4), and some of its [key concepts](https://dev.to/siddharthsing/5-building-blocks-of-blockchain-every-developer-should-know-3902). Now, we will be diving a little deep into blockchain and breaking down a single unit or a block in the blockchain and learning about it.


![Lets get started gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1jmnose0voq738wteeh.gif)

## Blockchain Structure

* One can imagine a Blockchain as a linked list. Similar to a Linked List the blocks of a blockchain are connected through something, that something in the linked list is the address of the previous node but in the blockchain, it is the Merkle-Hash value of the previous block, which is stored in the successor block.   

![Blockchain structure showing hash codes connecting the previous block](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2im6nd89d4rn8lhzpmp.png)

* An obvious question might arise in your mind, how many blocks 
  can be present in a blockchain?
  The answer is any number of blocks are possible, as long as the 
  maintainers are good with that. You can check this [link] 
  (https://bitinfocharts.com/ethereum/) to see how many blocks of 
  some famous blockchains are created to date.

* Here is an image of Ethereum's block count.

![Ethereum block count](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6wz0sn8g7f574wbia4w.png)

## Block Structure
* A block in a blockchain constitutes of two components, Header (which is further divided into six components) and Ledger - the main transaction database. Below is the image to roughly visualize a block in a blockchain.

![Block structure of a blockchain showing Block header - Version, Merkel Hash root, previous hash code, bits, timestamp and nonce  and block ledger with few transactions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgnmibd0qt59tyaw4etm.png)

* The block structure in the image above does not show all the components of the block's head, but I will be listing all of them in the next section.

### Block-Header
The Block-Header is an 80 bytes long string consisting of six components - 
- Version (4 bytes) 
- A hash code of the previous block (32 bytes)
- The current block's Merkle-Hash code value (32bytes)
- Timestamp (4 bytes)
- Bits (4 bytes) 
- Nonce value (4 bytes)


> **Version** - It is as the name is the version number of the protocol used in the chain.


> **Previous block hash** - The block header contains a 256-bit long Merkle Hash code value of the previous block to stay connected with the blockchain. The first block in any blockchain is called a **Genesis block** - A block that doesn't have any previous block hash.

> **Merkle Hash value** - Merkle hash code value of each block is a combination of all the hashes changed during each transaction in a block. It is a 256 bit long Hash code which acts as an identity or name for a block.

> **Timestamp** - Each block contains a [Unix time](https://en.wikipedia.org/wiki/Unix_time) timestamp. In addition to serving as a source of variation for the block hash, they also make it more difficult for an adversary to manipulate the block chain.

> **Bits** - Bits can be understood as a level of difficulty assigned to the miners for the process of proof-of-work. Adding a new block in a blockchain is a tremendously difficult task, miners have to solve a very tough mathematical puzzle (not literally a puzzle) in order to add a block. The difficulty of that puzzle is stored in the Bits field.

> **Nonce** - It is that puzzle that miners are trying to solve extensively to get rewarded. Nonce itself is a full article topic so I will not be emphasizing it too much here.

### Block Ledger
The Block ledger contains the details of all the transactions stored in a block. A block can store up to 2000 transactions. The maximum size a block can achieve is 1MB, depending upon the number of transactions recorded in a particular block. As long as the chain length increases it becomes impossible to update or manipulate these transactions and this makes the blockchain immutable.

## Conclusion 
That was all about the block structure of a blockchain, I covered all the components of the block's structure. Hope you like the article. More articles on this series coming every week, so stay tuned.

##Writer's Support
* If you find the article useful show some love ❤️ by following me on linkedin or github or instagram or twitter or everywhere 🤩.
 <div>
  <p>
<a href="https://twitter.com/SidharthSing20">
  <img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white">
  </a>
  <a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/">
  <img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white">
  </a>
  <a href="https://github.com/Siddharth-sing">
  <img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white">
  </a>
  <a href="https://dev.to/siddharthsing">
  <img src="https://img.shields.io/badge/dev.to-0A0A0A?style=for-the-badge&logo=dev.to&logoColor=white">
  </a>
<a href="https://www.instagram.com/i_m_siddharth.singh/">
  <img src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white">
  </a>
<p>


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2xzvand44haz2dpfayf.gif)