Blockchain: Understanding basics - part 1
Tags: blockchain, bitcoin, ethereum, web3
Published: 2023-04-27 13:12:02

---
title: Blockchain: Understanding basics - part 1
published: true
date: 2023-04-27 13:05:31 UTC
tags: blockchain, bitcoin, ethereum, web3
canonical_url: https://blog.vishnuprasaath.dev/blockchain-understanding-basics
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40kyoyee5yhe05mz9d31.png
---

In this article let's try to demystify and understand the basics of the blockchain infrastructure and see how it contributes to the **web3** ecosystem.

### **What is a blockchain?**

Basically **, blockchain is a Data Structure**. Very similar to other data structures like databases (rows, columns, tables), text files, CSV, images, lists, and so on. Blockchain competes most closely with a database.

For an analogy, let's visualize blockchain _as_ pages in a book  
**Chain = Book**  
**Block = Page**  
**Blocks in Chain = Pages in Book**  
Each page in a book contains:

- **text** : content/story

- **information about the page** : chapter number/title, page number

Similarly in a blockchain block, each block has:

- **contents** of the block: Transaction details in cryptocurrency, or any data which we prefer to store

- **header** : **Metadata** - data about the block. Some sort of technical info about the block, a reference to the previous block, and a fingerprint (hash) of the data for the current block

In blockchains, each block references the previous block by a computed hash value called the **blocks fingerprint**. The fingerprint is computed based on the **contents** of the block.

The concept of maintaining a reference to the previous blocks can be visualized as a **linked list structure**. In the linked list each node holds a reference to the next node, whereas in the blockchain each block holds a reference to the previous block.

![books_and_blocks](https://i0.wp.com/bitsonblocks.net/wp-content/uploads/2015/09/books_and_blocks.png?resize=570%2C129&ssl=1)

This creates the fancy structure called the **blockchain**!

* * *

The fingerprint in each block is responsible for taking care of the consistency and validity of the data. If someone tries to meddle with any of the data, they have to end up regenerating all the fingerprints from that point forwards and the blockchain will look different. This is basically impossible as the process of creating fingerprints is difficult and slow. Therefore, if someone wants to re-write parts of the blockchain, it will take them a long time, and they have to catch up with and overtake the rest of the honest network. Which is not feasible.

Hence the blockchain is called **immutable** (as it cannot be changed).

The below image shows the inside of a blockchain block: the fingerprints are unique to the blocks contents.

![block-chain-inside](https://cdn.hashnode.com/res/hashnode/image/upload/v1682595755311/91e67114-6349-4083-ae30-9c2de7184735.png)

* * *

### Data Distribution

There are two ways of distributing data in a network: Client-Server and Peer to peer. Blockchain is built on top of the **peer-to-peer** model.

![peer-to-peer and client-server](https://cdn.hashnode.com/res/hashnode/image/upload/v1682592527479/b730f1ac-9e8b-4fa8-8c28-cdb8cc47c980.png)

**Client-server**  
This is a traditional approach where the server holds 100% of the data, and the clients connect via required protocols to access/consume the data.

**Peer-to-peer**  
In peer-to-peer models, each peer has 100% of the data (or as close to it as possible), and updates are shared around. This is less efficient than client-server, as data is replicated many times. However, it's more robust as there is no central server that can be controlled, so closing down peer-to-peer networks is harder.

But on the contrary, the peer-to-peer model comes with its downsides. In the real world each peer on the network is gonna process and update at its own speed and latency and end up having varied states at a given timestamp. Deciding on which peer holds the valid data and which peer has stale or tampered data is ambiguous.

This conflict is resolved by a rule called the **longest chain rule** - If you see multiple blocks, treat the longest chain as legitimate. We can discuss in-depth on this conflict resolution and consensus in a separate article.
[blockchain-understanding-basics-part-2](https://dev.to/pvishnuprasaath/blockchain-understanding-basics-part-2-od5)

* * *

## Conclusion

Blockchain is not something that is associated with only **Bitcoin**. **Ethereum** is a great variant of blockchain with **smart contracts**. There are significant challenges involved.  
On the other hand, private or internally distributed ledgers and blockchains can be deployed to solve a wide range of problems and use cases.