How to create your own blockchain-based Cryptocurrency from Scratch!

What is a Blockchain?

Blockchain is a decentralized, distributed, and public ledger that contains records of transactions between parties. So, what do these heavy terms mean?! The Blockchain is ‘Decentralized’ because several ‘authorities’ have the power to make additions to Ledger. The Blockchain is ‘Distributed’ since anyone can take a look at its contents. Upon first glance, the whole concept seems absurd violating the very meaning of privacy. But after reading the blog you’ll agree that with a bit of Cryptographic magic this system is indeed quite interesting.

Working of BlockChain

Here is a simple model of the Blockchain we implemented.

Why Mine??

The Node to win the race in finding a suitable nonce gets a certain amount accredited to his account. This amount comes out of thin air and is the source of new currency in the system. This incentivizes the Nodes to use their Computational Power to mine the Blocks.
Another source of income for the nodes is that senders who want to make an urgent transaction can set aside some money for the Nodes which first mines the transaction. This encourages miners to put the transaction in the most recent Block to be mined.

Implementation

  • Check account balance
  • Make an alias
  • Transfer coins to another account
Output = {"recipient":public key,"amount": money_transferred }
[transaction ID][index][SHA256 hash]
Input > {"transactionId": transaction id ,"index": index , "signature": signature}
  • So with the essential ingredients at hand, you are all ready to mine a block. Now it's all just a race to see which node is able to mine the block the fastest. You take a bunch of pending transactions, check if they are valid and bundle them together, give them a partial blockhead(just some fields like a hash of parent block, index, target, hash ) and start mining. I called it partial as we would obtain two more fields after mining( timestamp and nonce). In the end, we would combine the complete blockhead to the block, process it (the tedious job we did while receiving blocks from peers), and send it to the rest of our peers.

I love to meet amazing people, share ideas and collaborate for revolutionary projects. Well , I am smart as well