Let’s start with what is currency, it is a medium of exchange of goods and services. In similar terms, cryptocurrency happens to be a form of currency that can be exchanged online for goods and services and is present in digital form only.
In a technical manner, it can be stated as “Cryptocurrency is a decentralized digital currency that uses encryption techniques to regulate the generation of currency units and to verify the transfer of funds. Anonymity, decentralization, and security are among their main features. Cryptocurrency is not regulated or tracked by any centralized authority, government, or bank.”
DEVELOPING YOUR OWN CRYPTO-CURRENCY
To develop our own crypto-currency we have to first understand how does it work.
Blockchain, a decentralized peer-to-peer (P2P) network, which is comprised of data blocks, is an integral part of cryptocurrency.
Now, A blockchain is a type of database that works as a decentralized peer-to-peer (P2P) network, which is comprised of the data blocks.
These data blocks store information about transactions and also validate new blocks. All these blocks are connected to form a chain. The data recorded in blocks cannot be altered without the alteration of all subsequent blocks.
Now let's get into the coding stuff, we have used Python to develop this project.
First of all building the basic structure for blockchain
from hashlib import sha256
hashing_text = ""; h = sha256()
for arg in args:
hashing_text += str(arg)
def __init__(self,number=0, previous_hash="0"*64, data=None,time1=time.asctime( time.localtime(time.time())), nonce=0):
self.data = data
self.number = number
self.previous_hash = previous_hash
self.nonce = nonce
return str("Block#: %s\nHash: %s\nPrevious: %s\nData: %s\nNonce: %s\nTime: %s\n" %(
difficulty = 4
self.chain = 
def add(self, block):
def remove(self, block):
def mine(self, block):
try: block.previous_hash = self.chain[-1].hash()
except IndexError: pass
if block.hash()[:self.difficulty] == "1" * self.difficulty:
block.nonce += 1
for i in range(1,len(self.chain)):
_previous = self.chain[i].previous_hash
_current = self.chain[i-1].hash()
if _previous != _current or _current[:self.difficulty] != "1"*self.difficulty:
Here we create two classes BLOCKCHAIN and BLOCK with various functions that are required.
A BLOCK consists of data, previous_hash, hash.
Data will contain transaction details of a particular transaction.
Previous Hash will be the Hash of the previous block connected.
Hash will return the calculated hash of the current block based on the details provided.
BLOCKCHAIN will consist of various blocks connected to each other it consists of functions like *isValid* to check if the current chain is valid or not.
The function *mine* calculates the hash in such a way that the first four digits always remain 1, this is done to implement the proof of work algorithm.
We have implemented this project using FLASK and MYSQL.
Github link to the project: https://github.com/koushal2001/CommonCoin
Comment below about your experience and any suggestion for the project!
And do clap if you like the content. Peace!