Project Assignment for Blockchain course
- Saksham Bansal
2020A3PS2129H
- Samarth Sharma
2020A3PS0615H
- Shaurya Garg
2020A8PS2215H
- Akshat Johar
2020A3PS1793H
- This project consists of building a blockchain system for land management.
- This project focuses on implementing Delegated Proof of Stake (DPoS) consensus algorithm
DPoS is a reliable, robust, scalable and efficient consensus algorithm in Blockchain technology. It is an innovation over standard Proof of Stake (PoS). In DPoS, each node that has a stake in the system can delegate the validation of a transaction to other nodes by voting.
Here, in DPoS, user's vote weight is proportional to their stake rather than block mining being tied to the stakeholders' total tokens.
Here we have defined some utility functions for perusal in our project at various places.
- To get the timestamp of the current transacation we get the time using getTimeNow function , convert it to UTC time and then into miliseconds.
- The formatted time we get is exported for use in blockchain.js, block.js
- A threshold is chosen randomly.
- Users become delegates when the corresponding value is greater than the threshold
- imported the SHA256 library to generate the hash function
- the following attributes have been given to a block : propertyID, previousHash,Hash, timestamp, transacation, merkele Root
- Function to calculate hash is defined which takes in the data as timestamp,propertyID, previoushash and merkle root of transactions
- Merkle Root function takes in the array of transactions. It then pairs up the transacation as needed in a binary tree and hashes them pair-wise. Finally the root hash is returned which is included in the block structure after being hashed with the current hash.
- Blockchain class is created with its constructor calling the createGenesisBlock function
- Inside Create Genesis Block we are passing the property ID as gicen by user and its own ID to transaction function (explained earlier)
- A new block is created which is passed on with properties of timestamp, block number and values returned from transaction function
- New users are added when a new block is added to the blockchain. Every user is assigned a random stake between 0 and 100 on creation.
This class is used to specify the buyerID, sellerID, and the timestamp of the transaction that occured.
- Make sure that you have Node.js installed on your machine
- cd to the Project
- Run
npm i
- Run blockchain.js file using
node blockchain.js
- Sample Blockchain
- Sample commands
- Output