- Node.js to run javascript
Clone the repository run >> *node main.js <...><...><...>
example: node main.js Alice Bob 10 Sender Reciever 20 OUTPUT:-
Block with Alice as its first transaction started...
Block with Sender as its last transaction mined successfully...
Mining Success
Miner's Bal: 0
Now Mining Miner's Block...
Block with null as its first transaction started...
Block with null as its last transaction mined successfully...
Mining Success
Miner's Bal: 10
Now Mining Miner's Block...
Block with null as its first transaction started...
Block with null as its last transaction mined successfully...
Mining Success
Miner's Bal: 20
Note: Here null refers to miners address since he is mining his own block so from address is null there
- This file when run first basically creates the first block called as the genesis block in crypto world also referred to as block 0.
- It then processes the command line arguments passed by the user where there are three arguments present for a single transaction and such multiple transactions can be present.
- It then processes those transaction using the proof-of-work concept and creates a block and puts it at the end of the last block already present.
- It is also used to mine the miners block which gets executed after miner adds a new block onto the network. Since he gets a reward i.e. he is rewarded a new cryptocoin after he succesfully mines a block and adds it to the network.
- As the name says, this creates blocks to hold the transactions.
- Not only this, it is also responsible for doing the most important thing which makes block chain most secure yeah, you guessed it right... It is responsible for calculating the hash value.
- It holds all the fields a transaction should contain.
- The From Address
- The To Address
- And The number of Coins to Transfer
Here comes the core part of this whole network which includes creating blocks from the pending transaction list and adding it to the chain once a proper hash value is found by the miner. And ya, it earns the miner a new crypto coin....
- We even have the getBalanceOf method which returns person's crypto wallet balance (yet to be implemented using the command line) which can be run by calling it from the main by passing the address as its parameter.
- We can even verify the validity of the blockchain using the isChainValid() method which returns a bool value based on its state.
[ ] Planning to create a UI for the same and add more functionalities once i get to know the whole indepth working of the blockchain.