Blockchain Technology

Blockchain, the technology behind cypto currencies like Bitcoin, Ethereum etc. is a loud buzzword in software industry. It comes up with new set of tools, initially used to develop softwares dealing with financial transactions but can now be extended to other areas as well.


The purpose of this article is to explain Blockchain Technology in simple words relating with day to day examples. It will be an introduction to blockchain without drilling into the complexities of Private Key cryptography and the likes.


Setting the correct expectation, lets begin by answering

What is BlockChain Technology?

To understand Blockchain Technology, let’s look into our day to day value transfer where a third party takes care of facilitating all the transactions in Centralized way for e.g banks for money, notary for land transfer etc maintaining a ledger.


This Centralization concentrates power in hands of few individuals.


What if we return power back to people by Decentralizing it?


In November 2008, Satoshi Nakamoto published a Whitepaper for a new monetary system which has two main characteristics,


This digital monetary system is famously known as Blockchain.


Then the question arises,

How does Blockchain Technology work

Blockchain maintains a Distributed Digital Ledger on peer to peer network of nodes to store all the transaction information.


Let’s drill into Distributed Digital Ledger by first defining


Ledger
A Ledger can be understood as an ordered list of transactions meant for book keeping.


A simple ledger is shown below maintaining records of all the value transfers between multiple parties,

Date Value Sender Receiver
2018-01-01 $10 Kamran Palash
2018-01-02 $12 Kamran Mayank


Digital Ledger
A Digital Ledger is the same ledger maintain over internet.


Distributed Digital Ledger
It means copy of the ledger maintained over internet exists on all the participating nodes on the network.


Moving on let’s look into

Characteristics of Blockchain Technology

  1. Replication: Each node stores all the data and has power to decide which modifications in data are legitimate
  2. Consistent: Data stored in all the nodes is consistent i.e. all nodes have identical copies of data. Consistency in individual copies of data is maintained by using Consensus Algorithm, Which states

    A central point is elected and is responsible to modify the data and other nodes consider it as one source of truth. This central point is changed on regular and random basis between nodes.

  3. Immutable: Immutability implies we can’t change history i.e. we can always track all the modifications from origin
  4. Trustless: Trustless environment implies nodes can join the network at any point in time, download data and start requesting changes without needing to trust them


Blockchain Technology


In simple words,

Blockchain is a distributed digital ledger, where each ledger is made of chain of blocks related to each other by hashes having transaction information on them.


Each block of blockchain consists of,


Let’s quickly look into a basic Java Implementation of Blockchain.


We have transaction.java class holding the details of individual transaction like source, destination and sum.

public class Transaction {

  private String source;
  private String destination;
  private Long sum;
}


A block.java class which acts as a blueprint of each block in Blockchain.

public class Block {

  private int previousHash; // <- HASH (Unique Identification Number of a block) of previous block
  private List<Transaction> transactionList; // <- Transaction information
}


BlockChain.java class simulates a simple blockchain, where transaction1 and transaction2 are two transactions present in first block. Second block contains hash of first block and transaction3.
This chain keeps on growing as and when new blocks are added.

public class BlockChain {

  public static void main(String[] args) {

    Transaction transaction1 = new Transaction("Kamran", "Palash", 1000L);
    Transaction transaction2 = new Transaction("Palash", "Prakhar", 110L);

    Block block1 = new Block(0, Arrays.asList(transaction1, transaction2));

    /*
     Block2 has hash of previous block.
    */
    Transaction transaction3 = new Transaction("Prakhar", "Mayank", 120L);
    Block block2 = new Block(block1.hashCode(), Arrays.asList(transaction3));

  }
}


In above example, we have seen how we are adding transaction information to new blocks and linking it to the previous chain of block. This new block is created by an elected node among all the participating nodes known as mining nodes.


This election is based on an algorithm, first being


Proof of Work

Proof of Work is a consensus algorithm in which computation power is deciding criteria to win an election.


Suppose we want to append a value transfer between A and B to Blockchain. Value transfer is represented as transaction in Blockchain. To append this transaction following steps occurs in sequence


Above algorithm is used in one of the most famous cryptocurrency, which is


Bitcoin
Bitcoin is primarily designed for digital cash system and its language is limited to avoid any shady business. We use Proof of Work Algorithm for consensus, which states

A Node solves a puzzle and once solution is proven and verified as correct; winner will get to decide which transactions get to append to ledger.



Proof of Stake

Proof of Stake is a consensus algorithm in which Economic Stakes are deciding criteria to win an election.


Stake can be defined as the amount of wealth (currency of that Blockchain) that a miner is willing to put on stake i.e. lock up for a certain amount of time. Higher the stake higher his chances to win the next election i.e getting the opportunity to mine next block and earn reward.


Conclusion
In conclusion, I would like to reiterate that Decentralized nature i.e. no central authority Or governing power and immutability of transactions are truly game changing features of blockchain.


We can use it to Conduct Elections, Money Transfer, Digital Agreements and what not.

References

SUBSCRIBE TO NEW CONTENT

Tutorials on System Design, BlockChain, Design Patterns and more sent out once a week.

Loading comments...