DEV Community

Cover image for Block by Block: Understanding Blockchain (Part 1)
Haaris Khatri
Haaris Khatri

Posted on

Block by Block: Understanding Blockchain (Part 1)

When you're starting out in the domain of blockchain , information can be quite overwhelming. There are lots of buzzwords that you come across which do sound good but aren't very clear. I faced similar issues when I started out . So , I've tried my level best to simplify it for absolute beginners to blockchain. You may skip this if you're an expert in the domain.

What is Blockchain?

Blockchain, at its core, is an immutable ledger, a record of transactions that cannot be altered. Information is hashed using cryptographic algorithms into blocks which are then connected to each other. Hence , the term 'block'+'chain'.

How Does a Blockchain Work?

Here's a simplified explanation:

1 -> Transaction: When a transaction occurs, it's broadcasted to all nodes in the network. The transaction details include the sender's and receiver's addresses and the amount transferred.

Transaction flow in blockchain shown using blocks

2 -> Block Creation: Transactions are grouped into a 'block'. Each block contains a unique code called a 'hash' and the hash of the previous block in the chain, linking the blocks in a chronological 'chain'.

Transaction flow in blockchain shown using blocks

3 -> Verification: Nodes validate the transactions in the block, checking if the sender has sufficient balance for the transaction and if the transaction hasn't been tampered with.
If any block is tampered , that shall change the hash value and so all other blocks will reject it. This is why blockchain is secure.

Transaction flow in blockchain shown using blocks

4 -> Consensus: Once a block is verified, it needs to be added to the blockchain. The nodes agree on the block's validity through a process called 'consensus'. In Bitcoin, this is achieved through 'Proof of Work'. However, there are many other consensus algorithms. This basically checks whether the provided information satisfies the rules of the network and the state of ledger.

Blockchain consensus

5 -> Adding the Block: After consensus is reached, the block is added to the chain. This update is propagated throughout the network, and the block becomes a permanent transaction record.

For more information, check this link. It lets you simulate the workflow.

Types of Blockchain

Based on its architecture and operation, blockchain can be classified into two types:

  1. Public Blockchain: This is the well-known version that includes cryptocurrencies like Bitcoin and Ethereum. As the name suggests, it's open to everyone and truly decentralized.

  2. Private Blockchain: This version is less popular. It operates on the same fundamentals but is permissioned, meaning not everyone is allowed. An example is Hyperledger Fabric.

In simple terms, the differences are:

- Public Blockchain:

  • đź’° Transaction fees is applied to every transaction. (e.g., Ethereum, Solana).
  • âś… Open to Everyone.

- Private Blockchain:

  • ❌ No transaction fees (e.g., Hyperledger Fabric, R3 Corda).
  • đź›— Only selected individuals are welcome.

Image Credits : [](https://101blockchains.com/public-vs-private-blockchain/)
Image Credits : This image is from : 101 Blockchains

Hyperledger Fabric

Hyperledger Fabric Logo

I'll be focusing on private blockchain, specifically Hyperledger Fabric, as it's the one I've worked with most.

Hyperledger Fabric is akin to a Lego set for building blockchains. It helps businesses create secure, private blockchains to track transactions or any other data. Access to these chains can be restricted based on company policies.

You can host your Hyperledger Fabric network on your own infrastructure, whether it's Docker-based or Kubernetes. Kubernetes is commonly used for production-grade networks.

Components of a Hyperledger Fabric Network

Here's a basic introduction to the components in a Hyperledger Fabric network. I'll cover them in more detail in the next blog:

  1. Certificate Authority (CA): Your identity in a Hyperledger Fabric-based network is created and managed using certificates generated by the Certificate Authority. All the access within the network is regulated using these certificates.

  2. Orderer Nodes: These nodes apply consensus and operations related to adding blocks and validations. There are various consensus algorithms that these can run.

  3. Chaincodes: This is where the business logic is written for different organization members. This is where you write code. As of now , it can be written in go, java or javascript.

  4. Peers: Peers are nodes owned by organizations. They maintain the ledger, run the chaincode (business logic), and participate in the validation and addition of transactions to the blockchain.

  5. Channels: These are sub-networks within the blockchain network. These sub-networks are isolated from each other.

In the next blog, I'll delve into detailed explanations of network components and also steps to setting up a network on the Kubernetes cluster.

Top comments (0)