Skip to content

the-ayush-singh/blockchain

Repository files navigation

Blockchain

Blockchain

Testing Blockchain to Create a Cryptocurrency like Bitcoin, DogeCoin, etc.

BitcoinDogeCoin

It utilizes Basic JS concepts(OOPs, Arrow Functions, Modules,etc..) arranged in a logical way.

Node Js Programming Environment is used here.

Here we're generating Blocks with their unique Hashes using (SHA 256)

Testing the Hash Function

Testing all the commits(like Blockchain Validation, Mining function, etc)! Just to be On safe Sides 😀

Here NodeMon is used to Leverage auto run facility

Testing Validation Function

Creating and Testing APIs using POSTMAN

Postman

Linked various peers through websocket and SYNC the Blockchain

Peers connection display in Terminal

Creating BLOCKS using postman and Syncing it through WebSocket

Postman generating POST Requests(Blocks)

PROOF OF WORK

Adding difficulty to the Blockchain so that it cannot be exploited.

We can see that at DIFFICULTY = 4 there are four zeros in the beginning of the Hash

With DIFFICULTY = 4 the time taken to generate the block is about 4 sec.

DIFFICULTY AT 4

With DIFFICULTY = 5 there are five (0)s in the begining of the Hash and Time taken to generate the Block is about 47s.

Therefore we can observe that time increases exponentially as difficulty increases, therefore DIFFICULTY helps the Blockchain to prevent its exploitation! As more and more resource of the MINER will be utilised for mining the chain. Therefore if someone wants to replace the whole chain they will need about 51% power of the total Blockchain system and even after doing so it won't be worth it.

DIFFICULTY AT 5

Generating a Blockchain with Dynamic DIFFICULTY

Here difficulty is varying according to the time taken by previous Block production.

Blocks with Dynamic DIFFICULTY

Creating Crypto Wallets

Wallets are used to store blocks/cryptocurrencies. It helps users to protect, authenticate as well as transact their Cryptos/Blocks. Wallet

Transactions

Transaction contain a unique ID, address of the sender's and the recipient's wallet, amount to be transferred.

Transaction object is divided into two parts - Input and Output.

Transaction Tests

Verifying Transactions

We can verify the incoming transaction using SHA256 and keyFromPublic() function in JavaScript imported from ec module.

Transaction Verification test

Updating Transactions

To make transaction object more efficient and optimised we can update it, if transaction is being made to the same user multiple times.

Updation Verification test