DEV Community

Cover image for Blockchain Block Anatomy
Siddharth Singh Baghel
Siddharth Singh Baghel

Posted on

Blockchain Block Anatomy

So far in this article series, we have discussed the Blockchain, its roadmap, and some of its key concepts. 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

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

  • 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 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

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

  • 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 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 🤩.

    Image description

Top comments (3)

Collapse
 
siddharthsin profile image
Tony Gunk

Awaiting nonce article.

Collapse
 
siddharthsing profile image
Siddharth Singh Baghel

That I will cover in the article of Miners and how do they mine a block.

Collapse
 
siddharthsing profile image
Siddharth Singh Baghel

Ever thought of how a single block looks like in a blockchain. Have a look on the article.