Java + Spring Boot implementation of Blockchain

Author: Shazin Sadakath


Blockchain is the buzz word these days as it is technology used by Cryptocurrencies which is taking over the world like crazy. There are so many articles written on the Theory of Blockchain like this one but there are very little implementations. But recently I stumbled upon an article by Daniel van Flymen who happens to have written a Python based implementation of the Blockchain.

 

According to him and I am pretty sure many Software Engineers would agree that the best way to learn something is to actually implement it so that you learn more than you get to learn while reading theory documentation.

 

So this inspired me to write Java + Spring Boot based Implementation of Daniel's work so that I can learn the Blockchain workings. For everyone who is interested following is a basic version of how a Blockchain will look like in the wild.

{
    "chain": [
        {
            "index": 1,
            "timestamp": 1507040257518,
            "transactions": [],
            "proof": 100,
            "previousHash": "1"
        },
        {
            "index": 2,
            "timestamp": 1507040265932,
            "transactions": [
                {
                    "sender": "0",
                    "recipient": "6e79c809332146b381e4a05b3a3611b4",
                    "amount": 1
                }
            ],
            "proof": 15347,
            "previousHash": "05b63a2e2967e272c697bd9a42808f3e058665f597dd00d90c45fded87dea36f"
        },
        {
            "index": 3,
            "timestamp": 1507040267619,
            "transactions": [
                {
                    "sender": "0",
                    "recipient": "6e79c809332146b381e4a05b3a3611b4",
                    "amount": 1
                }
            ],
            "proof": 149703,
            "previousHash": "2448e433664129f419d6b140989e4c1c5be1f39751f3eec3d7b5a31c9930570d"
        },
        {
            "index": 4,
            "timestamp": 1507040270049,
            "transactions": [
                {
                    "sender": "0",
                    "recipient": "6e79c809332146b381e4a05b3a3611b4",
                    "amount": 1
                }
            ],
            "proof": 30689,
            "previousHash": "580acc47987af4f9b5aa939b05282393d1406bf52ea836755e0cbeb99acc8b74"
        }
    ],
    "length": 4
}

So Daniel talks a lot about the details of the Blockchain which you can read but in short following are the Steps required to write a Blockchain implementation.
 

  1. Building a Blockchain
  2. Building an API to access the Blockchain
  3. Interacting with the Blockchain 
  4. Consensus

You can see all above Steps implemented in Java + Spring Boot at https://github.com/shazin/block-chain

 

 



Tags: Blockchain Bitcoin CryptoCurrency SpringBoot
Views: 973
Register for more exciting articles

Comments

Please login or register to post a comment.


There are currently no comments.