Skip to main content

Introduction to Blockchain - Architectural Overview (Part 3)

In today's post, we will look into the architectural details of the blockchain technology. In doing so, we will touch upon the concepts of Smart Contracts and later on, about the internal details of a block that comprises the Bitcoin blockchain.

Interesting project but no money ☹️

Let us say your friend Alice has an interesting project idea and she wants to start it as soon as possible but she has no (or little) funding to start it. She is very upset and then as a good friend you come to her rescue (A friend in need is a friend indeed 😊). You suggest her that she should crowdfund the project. She is now intrigued and inquires about it.

What is crowdfunding and how it works?

Put simply, crowdfunding is the process of getting a large crowd of people to pay a small amount of money to invest in an idea or product, with the promise that when the said idea comes to fruition, they will get first access to it. The idea can be anything, from an innovative piece of tech to a video game to a novelty gift. 
  • Both the product team and the supporters need to trust the crowdfunding platform (or a Kickstarter).
  • The product team expects the money to be paid as the project progresses. 
  • The supporters expect the money to go to the project.
As it is clear that this is a centralized system and the major drawback is that some monetary benefit goes to the Kickstarter for their efforts in managing the entire process. The solution to this problem leads us to the concept of "Smart Contracts" which is a decentralized version of the same platform.

Smart Contracts

In 1994, Nick Szabo realized that a decentralized system could be used for smart contracts or self-executing contracts. Here, contracts are converted into computer code, stored and replicated on the system and supervised by the network of computers that run the blockchain. 

Thus, smart contracts help us exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman.

The best way to describe smart contracts is to compare the technology to a vending machine. Ordinarily, you would go to a lawyer or a notary, pay them, and wait while you get the document. With smart contracts, you simply drop a bitcoin into the vending machine (i.e. ledger), and your escrow, driver’s license, or whatever drops into your account. More so, smart contracts not only define the rules and penalties around an agreement in the same way that a traditional contract does, but also automatically enforce those obligations.

if we apply Smart Contracts to our example of crowdfunding, then the following things will happen -
  1. The contract is written in a "code" which is available to the stakeholders - product team (Alice) and the supporters (Note - a typical example of a blockchain)
  2. The code automatically transfers money as certain goals (contracts) of the project are accomplished.
  3. If the project goals (or contracts) fail, then the code will transfer money back to the supporters.

 Advantages of Smart Contracts

  • Immutable - No party will be able to change the contract once it is written to the public ledger.
  • Distributed - Every stakeholder can validate the contract

Block in a blockchain - Securing data cryptographically

In this section, we will look into the nitty gritty details of the fundamental entity in a blockchain, that is, the block. A chain of many such blocks makes a blockchain. On high level, a block has two components - 
  1. Block Header
  2. Transactions
Let us look into these components one by one -

Block Header

The header contains metadata about a block. There are three different sets of metadata:

  • The previous block hash - in a blockchain, every block inherits from the previous block as it uses the previous block's hash to create the new block's hash. For every block N, the hash of the block N-1 is used.
  • Mining competition - each block in a blockchain has the timestamp, the nonce and the difficulty. It should be complicated enough to make the block tamper-proof. The nonce is a random variable that makes it possible for the hash of the Nth block with predefined complexity. For e.g., for bitcoin, this complexity is that there should be 20 zeros at the prefix.
  • Merkle tree root - data structure that summarizes the transactions in the block.The root is the verification of all the transactions. I discussed Merkle algorithm in detail in my first post here.


Transactions are organized as a Merkle Tree whose root is used to construct the block hash. A Merkle tree is constructed by recursively hashing pairs of nodes ( in this case, transactions ), until there is only one hash, called the root or Merkle root. If we stay in the Bitcoin world, the cryptographic hash algorithm used is SHA256. This is applied twice each time.
This link discusses the Merkle tree in more detail. 

This provides us the capability to determine almost accurately if someone tampers a block. If some malicious attacker tries to tamper one transaction, then the hash of that transaction will be changed and thus there will be changes in the hashes of the subsequent blocks. Thus complexity of determing the hash of a block is so tough that it would take a lot of computing power and time to corrupt the subsequent blocks before a new block is generated. Thus, it is almost impossible for a attacker to reach the end of the blocks and making all of them corrupt.

Blockchain Replicas

  • Every peer in a blockchain network maintains a local copy of the blockchain.
  • All the replicas need to be updated with the latest mined block.
  • All the replicas need to be consistent i.e. all the copies of the blockchain with peers must be exactly similar.

Distributed Consensus

Distributed consensus, also known as Nakamoto consensus, is a method of establishing canonical state in a system. Think of it this way: There are an infinite amount of possible wrong answers, but only one right answer. In typical systems, this is done by a central authority that determines validity and provides data, also known as a trusted third party (TTP). 

The problem of infinite wrong answers means there must be a way to find validity in blocks. Instead of using a central authority, distributed nodes receive new blocks, and either choose to withhold or propagate them. In such a system, there is assumed to be an “uncoordinated, honest majority” that prevents a few malicious nodes from propagating incorrect blocks. This is also called Byzantine Fault Tolerance (BFT). 

Using the consensus rules of Bitcoin, for example, transactions must have valid signatures, originating from spends that are available (there must be enough balance to spend), be put into a Merkle tree with SHA-256d, and have a Hashcash-style proof of work attached that is under the widely agreed upon network difficulty, and other rules. If there are multiple blocks that are valid but branch off at some point, pick the longest series of blocks. Ultimately, because there is such an overwhelming majority that follows Bitcoin consensus rules exactly as they are written, consensus can be established through the Internet without any real problems. 

Few key points related to distributed consensus are - 
  1. Ensure that all the nodes in the network see the same data at nearly the same point of time.
  2.  All nodes need to agree on a regualr basis, that the data stored by them are same.
  3. No single point of failure - as the data is decentralized
  4. Challenge-Response Protocol - In this, the network poses a challenge to the peers. The node thay solves the challenge first declares that it has solved the challenge and the transaction is veirfied.
  5. Good challenge is the one in which different nodes win in different runs of the challenge. This ensures that no single node controls the network.
  6. Proof of Work - this ensures consensus over a permissions-less setting based on challenge-response.

Economics of Blockchain consensus

The challenge-response requires that every node spends large amount of computation power to solve a mathematical challenge in each iteration of the consensus. But why should they do it? What is the incentive for them? The answer to these questions is that when a node expends computational power to solve the problem, they are paid by the cryptocurrency generated and managed by the network.

With this, we have reached the end of this post. In this post, we discussed the architecture of a blockchain on a high level along with a good application - Smart Contracts.
In the next post, we will further explore the concepts of blockchain. Stay tuned 😊


  1. I’m genuinely impressed with your knowledge. You have great knowledge architectural drafting . It was a really attractive blog. Please keep sharing your post with us.
    architectural drafting services


Post a Comment

Popular posts from this blog

Introduction to Blockchain - Conceptualization and Applications (Part 4)

It's been a long time since my last post as I got stuck in some work. This is the last part of the introduction to blockchain series. In this post, we will touch upon a few more concepts of blockchain and their applications. At the end of the post, we will also look into the concept of Hyperledger Fabric in brief. Permission-less model In this model, anyone can join the network, participate in the process of block verification to create consensus and also create smart contracts. For e.g. Bitcoin and Ethereum network.  In a permissionless world, one does not have to prove their identity to the ledger.  As long as you are willing to commit processing power to be part of the network and extending the blockchain, you are allowed to play.  Any miner who is playing the game by the rule may be able to solve the hash puzzle and verify the block of transactions to win the mining reward (Higher the mining power, better the chances of winning the mining reward). It is good for fin

Introduction to Blockchain - Evolution (Part 2)

In the last part of this series , we discussed the basic concepts of blockchain technology. In this post, we are going to discuss the evolution of blockchain and it the latter part of the post, I will introduce the concept of bitcoin technology at a high level. Hashing and Hash Functions The concept of hashing is the backbone of the blockchain technology and it helps us to speed up the searching process. Hashing allows us to map any data to a fixed size. The entity which performs hashing is called a Hash Function. For e.g, H(x) = x%n ( % is the modulo operator - returns remainder when x is divided by n ) , as it is evident that x can be of any value but H(x) will always be in the range [0, n-1] . x is called Message H(x) is called Message Digest Cryptographic Hash Function It is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash). It is a one-way function i.e. we can find H(x) if x and n are given but if H(x) and n

Introduction to Blockchain - Basics (Part 1)

The blockchain isn't just the backbone of cryptocurrency - it could change the world. Applications are endless. It is one of the most sought-after skills these days. Blockchain developers are in huge demand but there are only a few who can elegantly develop a blockchain application. I will admit that I am a newbie to this field and all the related terminology. Recently I have decided to dive into this field and after learning a few nuances, I thought it would be a good idea to share my understanding with everyone. Hence, this blog. This is the first blog of this series and without further ado let's learn together the awesome concepts of Blockchain technology.  What is a blockchain? It is a decentralized  platform which enables multiple domains , who do not trust each other to collaborate in a decision-making process . Main keywords from the above definition are -  Decentralized - There is no single centralized authority that makes decisions on behalf of a