We hang out a lot. And we spend a lot. And sometimes we loose track of who ows how much to whom .
So we allot one person the power of handelling a ledger. And we trust him to keep track of all the transactions. But what if he makes a mistake? Or what if he is not honest? Or what if he is not available?
Well we dont seem to trust our friends (🤫 I didn't say that). So??
Why not use a decentralised ledger system?
A decentralised ledger system is a system where the ledger is not maintained by a single person but by a group of people. And the ledger is not stored in a single place but in multiple places. And the ledger is not controlled by a single entity but by multiple entities.
The ledger is maintained by a group of people called nodes (here, wallets). Each wallet has a copy of the ledger. And each wallet has the power to add a transaction to the ledger. And each wallet has the power to validate a transaction.
To validate a transaction, each person that is sending has to sign the transaction. The signature is made by the private key of the sending wallet. And the signature is verified by the public key of the other wallets.
Since the ledger is maintained by multiple nodes, it is difficult to tamper with the ledger. And since the ledger is maintained by multiple nodes, it is difficult to loose the ledger. And since the ledger is maintained by multiple nodes, it is difficult to make a mistake in the ledger.
We implemented a decentralised ledger system using blockchain. A blockchain is a chain of blocks where each block contains a list of transactions. And each block is linked to the previous block. And each block is validated by the nodes.
- I have a ledger with 1000 coins.
- I want to give 100 coins to Mohil.
- I create a transaction, send coins to Mohil.
- I update my own ledger.
- I sign the tranasction with my
pirvate key. - I broadcast the transaction everyone else.
- Everyone else validate the transaction. How? They check my
public keyand mysignature. They run an function which will return a boolean value showing if the signature made by thepublic keyassociated with theprivate keyis valid or not. - If the transaction is valid, everyone else add the transaction to the ledger.
- Everyone create a node containing the transaction.
- They update their own ledger.
- Then we check if everyone's ledger is same and honest. We see the last node of the ledger. We check the hash. If the hash is same, we are good to go. If not, we have to see which majority ledger is correct and report the rest of the ledgers.
-
Clone the repository
-
Run the bash file to compile and run the code:
./run.shIf you get a permission denied error, run
chmod +x run.shand then run./run.sh -
Follow the instructions on the terminal
-
Enjoy
☺️
Note: You need to have
c++11compiler installed on your system to run the code. Compile it using:g++ -std=c++11 main.cpp
- Aarav Singh Luthra
- Aryan Daga
- Mohil A
- Niyati Singh
- Preesha K
- Vardhaman Kalloli

