/CollegeCrypto

A cryptocurrency made for college project implemented on self made blockchain

Primary LanguagePython

CollegeCrypto

Table of Contents

  1. Abstract
  2. Scope of the Project
  3. Requirement Analysis
  4. Tools and Technologies
  5. Implementation
  6. Working and Explaination
  7. Setup
  8. References

ABSTRACT

“With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless.” – Satoshi Nakamoto.

Today, it is estimated that approximately 46 million people own Bitcoin. Bitcoin is only one of the many cryptocurrencies. A recent report stated that there are over 6,500 cryptocurrencies. Many of them have a low trading volume, but some have high trading volumes and are very popular.

Cryptocurrency is one of the words we can’t avoid these days. News, blogs and even big-time financial authorities obsess over it, and by now everyone has to admit: the world is changing in front of our eyes. Were it not for one particular use of blockchain technology, the current blockchain revolution would most likely have gone unnoticed by the majority of people outside the tech industry. This use was, of course, the cryptocurrency. The reason for this is not only that Bitcoin came first, but also the fact that there is a limit to the number of cryptocurrency that can be created. This effectively made bitcoin into what has been termed ‘digital gold’. As a result, more and more people who had little to no knowledge whatsoever of cryptocurrencies flocked to buy Bitcoin. So great was the influx that between October and November 2017, the price of a single coin rose from around $5,500 to over $10,000. Today that figure is many, many times higher.

Now, while no one expects all of these 6.500 current cryptocurrencies to succeed, including the most popular ones like Bitcoin, Ripple, and Ethereum, are available and the number is still growing, it certainly makes sense that the overall number is set to multiply dramatically over the next few years.All of the above information makes companies see the benefits of blockchain and makes them think about how to create a cryptocurrency.

SCOPE OF THE PROJECT

Some of the limitations that cryptocurrencies presently face – such as the fact that one’s digital fortune

can be erased by a computer crash, or that a virtual vault may be ransacked by a hacker – may be

overcome in time through technological advances. What will be harder to surmount is the basic paradox

that bedevils cryptocurrencies – the more popular they become, the more regulation and government

scrutiny they are likely to attract, which erodes the fundamental premise for their existence.

While the number of merchants who accept cryptocurrencies has steadily increased, they are still very

much in the minority. For cryptocurrencies to become more widely used, they have to first gain

widespread acceptance among consumers. However, their relative complexity compared to conventional

currencies will likely deter most people, except for the technologically adept.

A cryptocurrency that aspires to become part of the mainstream financial system may have to satisfy

widely divergent criteria. It would need to be mathematically complex (to avoid fraud and hacker attacks)

but easy for consumers to understand; decentralized but with adequate consumer safeguards and

protection; and preserve user anonymity without being a conduit for tax evasion, money laundering and

other nefarious activities. Since these are formidable criteria to satisfy, is it possible that the most popular

cryptocurrency in a few years’ time could have attributes that fall in between heavily-regulated fiat

currencies and today’s cryptocurrencies? While that possibility looks remote, there is little doubt that as

the leading cryptocurrency at present, Bitcoin’s success (or lack thereof) in dealing with the challenges it

faces may determine the fortunes of other cryptocurrencies in the years ahead.

WEB3

Web 3.0 was originally called the Semantic Web by World Wide Web inventor Tim Berners-Lee, and was aimed at being a more autonomous, intelligent, and open internet. In the Web 3.0, data will be interconnected in a decentralized way, which would be a huge leap forward to our current generation of the internet (Web 2.0), where data is mostly stored in centralized repositories. As Web 3.0 networks will operate through decentralized protocols — the founding blocks of blockchain and cryptocurrency technology — we can expect to see a strong convergence and symbiotic relationship between these three technologies and other fields.

Requirement Analysis

Non-functional requirements:

2.1 Non-functional requirements

Non-functional requirements are product constraints or the features the system provides. They include constraints on timing, technology limits, and limitations imposed by standards.

UX Design. One unique obstacle to the creation ofblockchain is the complexity of the user interface. The value of the blockchain assets is usually backed by the value of a cryptocurrency coin, provided by an initial coin offering (ICO). If the customer's wealth is connected to the coin's value, then how do you tell them their net worth increases and decreases as the value of the cryptocurrency increases and declines? When they are using your website, are they now investors in cryptocurrency? It is critical from the perspective of the user experience, too. Applications should be user friendly. For a new consumer, this first experience is very significant. Launching and cluttering a website with blockchain-related jargon is likely to put off most consumers. But dumbing it down can reduce the importance of it or the visibility of blockchain's main benefits that distinguish your application from the non-blockchain competition.

Scalability: If the platform is connected to an implementationof a blockchain such as Ethereum then it’s also connected to the scalability of the underlying network. Ethereum currently runs up to a theoretical limit of 25 (based on proof of work) at 4 transactions a second. When the next Ethereum game begins, a lot of transactions are created, would this affect the consumers? If they needed it, could they get their assets out immediately? Consumers would like to realize that they are not bound to something and will be able to return to the non-digital world at any stage of their choosing. To this, it is important to choose the right underlying platform.

Development Operations: As blockchain is still emerging, the technology to build the blockchain-based system is still evolving. It takes time to integrate new functionality into the system and improve the DevOps experience. Therefore, there should be enough time associated with the development phase.

Managing Stakeholders: There is a tendency to over-sellthe benefits of governance while marketing the advantages of a blockchain program. Possibly the actors of governance (e.g. police, government, auditors) get the most benefits from being able to monitor what everybody is doing and use it to control or test enforcement. It is necessary but other stakeholders need opportunities to enter the network otherwise there would be no users and no regulatory or control transactions. And there is the question of persuading all the stakeholders to get involved so you can do market research and collecting requirements. Modeling and smart contract concepts ensure that all various types of stakeholders recognize the company domains. It requires the views of several stakeholders to address the problem of what should be held in the blockchain. Finally, who initiates and pays for the creation of the blockchain platform initiative? Blockchain's key advantage is that it can facilitate business and collaboration among organizations that have never met. Over the platform's lifespan, this would attract many organizations, but one company needs to take the initial step, see the benefit, and create the platform for everyone else to use.

Functional requirements:

Tokenization: It is one of the most important thingsyou have to understand when talking about Blockchain. And most of us associate with Token things like speculative coins, ICOs and such things but tokens are much more than this. Tokens allows you to create digital representations for goods, services or rights. They can be fungible or non-fungible depending on the good or the service behind. Tokens can give you access to information about the product they represent, grant you some specific usage rights or represent the ownership of goods. These mechanisms are highly relevant for all digitization of real world goods use cases, because this allows trust and values to be exchanged between different parties without the need for a central intermediary.

Data security and privacy: These are very importantrequirements, especially for business use. There are two main issues with Blockchain. The first is that it must be possible to grant specific data access rights to individual users or roles. That’s very important because in a public chain like Bitcoin, all data within a block is readable by everyone. The second issue is compliance with data privacy regulation. Especially in Europe we do have a very tough data privacy regulation (General Data Protection Regulation). So we are faced with issues like for instance that there is a right to be forgotten within the GDPR or the requirement to have a data processing agreement with the data provider, which could be a big challenge in a decentralized system.

Decentralized data storage: It is a very core requirementof a distributed system. It must be possible to manage transactions and data storage in an efficient way. Sure, if decentralized data storage is your only requirement, there would be better solutions than Blockchain that solve that problem but obviously, the capability to manage data in a decentralized, distributed way is a fundamental requirement.

Smart Contracts: Smart Contracts are the most interestingpart of Blockchain systems. While a standard contract defines only the terms of a business relationship, a Smart Contract is able to define also the conditions under which the contract is executed. A Smart Contract is a set of fixed rules, defined as a software program, executed on the Blockchain. Examples you can define with a Smart Contract are: The definition of criteria under which a payment is made, the definition of quality criteria and the rules if these are not observed. Because such coded and tamper-proof executed rules can eliminate a central authority, Smart Contracts play an important role in automating cross-company collaboration.

Immutability: It is the property most associated withBlockchain. Immutability is the foundational requirement for exchanging value in a digital way. This requirement is not solvable with traditional internet technology because all digital data can be easily copied and changed. If two accounts exchange information for instance by mail, there is a copy of this mail in everyone’s mailbox. Same is for data, exchanged between two or more systems. The only way to solve that problem without Blockchain is relying on a central intermediary which holds the correct version of the data. Based on the Consensus mechanism, Blockchain is able to solve that problem by technology.

Permanent availability of data: It is the last corerequirement of Blockchain solutions. The ledger never forgets anything — which could be a problem in aspects of GDPR compliance, it’s an essential feature of blockchain technology. Especially when Blockchain is used to represent real contracts and their data,

immutability and permanent availability are essential requirements especially from a legal and regulatory point of view.

2.3 Used Modules.

Blockchain A blockchain is a distributed database that is shared among the nodes of a computer network. As a database, a blockchain stores information electronically in digital format. Blockchains are best known for their crucial role in cryptocurrency systems, such as Bitcoin, for maintaining a secure and decentralized record of transactions. The innovation with a blockchain is that it guarantees the fidelity and security of a record of data and generates trust without the need for a trusted third party. One key difference between a typical database and a blockchain is how the data is structured. A blockchain collects information together in groups, known as blocks, that hold sets of information. Blocks have certain storage capacities and, when filled, are closed and linked to the previously filled block, forming a chain of data known as the blockchain. All new information that follows that freshly added block is compiled into a newly formed block that will then also be added to the chain once filled. A database usually structures its data into tables, whereas a blockchain, like its name implies, structures its data into chunks (blocks) that are strung together. This data structure inherently makes an irreversible timeline of data when implemented in a decentralized nature. When a block is filled, it is set in stone and becomes a part of this timeline. Each block in the chain is given an exact time stamp when it is added to the chain.

Cryptocurrency A cryptocurrency is a digital or virtual currency that is secured by cryptography, which makes it nearly impossible to counterfeit or double-spend. Many cryptocurrencies are decentralized networks based on blockchain technology—a distributed ledger enforced by a disparate network of computers. A defining feature of cryptocurrencies is that they are generally not issued by any central authority, rendering them theoretically immune to government interference or manipulation. It’s a peer-to-peer system that can enable anyone anywhere to send and receive payments. Instead of being physical money carried around and exchanged in the real world, cryptocurrency payments exist purely as digital entries to an online database describing specific transactions. When you transfer cryptocurrency funds, the transactions are recorded in a public ledger. Cryptocurrency is stored in digital wallets. Cryptocurrency received its name because it uses encryption to verify transactions. This means advanced coding is involved in storing and transmitting cryptocurrency data between wallets and to public ledgers. The aim of encryption is to provide security and safety. The first cryptocurrency was Bitcoin, which was founded in 2009 and remains the best known today. Much of the interest in cryptocurrencies is to trade for profit, with speculators at times driving prices skyward.

TOOLS & TECHNOLOGIES

3.1 TOOLS:

The various tool which are used are listed below:

JSON: JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. Squarespace uses JSON to store and organize site content created with the CMS.

PYTHON 3.9. Python is an interpreted high-level general-purpose programming language. It is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented and functional programming.

POSTMAN API The Postman API endpoints enable you to integrate Postman within your development toolchain. You can add new collections, update existing collections, update environments, and add and run monitors directly through the API. This enables you to programmatically access data stored in your Postman account. You can get started with the API by forking its collection. For more details, see the Postman API documentation. You will need an API key to access the Postman API.

Flask: Flask is a web framework, it’s a Python module that lets you develop web applications easily. It has a small and easy-to-extend core: it’s a microframework that doesn’t include an ORM (Object Relational Manager) or such features. It does have many cool features like url routing, template engine. It is a WSGI web app framework.

ANACONDA: Anaconda is a distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment. The distribution includes data-science packages suitable for Windows, Linux, and macOS

3.2 TECHNOLOGIES:

The various technologies which we’ve used are listed below:

Hashing Algorithm Used:

SHA256: The SHA-256 algorithm is one flavor of SHA-2 (Secure Hash Algorithm 2), which was created by the National Security Agency in 2001 as a successor to SHA-1. SHA-256 is a patented cryptographic hash function that outputs a value that is 256 bits long.

In encryption, data is transformed into a secure format that is unreadable unless the recipient has a key. In its encrypted form, the data may be of unlimited size, often just as long as when unencrypted. In hashing, by contrast, data of arbitrary size is mapped to data of fixed size. For example, a 512-bit string of data would be transformed into a 256-bit string through SHA- hashing. In cryptographic hashing, the hashed data is modified in a way that makes it completely unreadable. It would be virtually impossible to convert the 256-bit hash mentioned above back to its original 512-bit form. So why would you want to create a scrambled message that can’t be recovered? The most common reason is to verify the content of data that must be kept secret. For example, hashing is used to verify the integrity of secure messages and files. The hash code of a secure file can be posted publicly so users who download the file can confirm they have an authentic version without the contents of the file being revealed. Hashes are similarly used to verify digital signatures.

CONSENSUS ALGORITHM: A consensus algorithm is a procedure through which all the peers of the Blockchain network reach a common agreement about the present state of the distributed ledger. In this way, consensus algorithms achieve reliability in the Blockchain network and establish trust between unknown peers in a distributed computing environment. Essentially, the consensus protocol makes sure that every new block that is added to the Blockchain is the one and only version of the truth that is agreed upon by all the nodes in the Blockchain.

PROOF OF WORK CONSENSUS The Proof of Work consensus algorithm involves solving a computational challenging puzzle in order to create new blocks in the Bitcoin blockchain. Colloquially, the process is known as ‘mining’, and the nodes in the network that engage in mining are known as ‘miners’. The incentive for mining transactions lies in economic payoffs, where competing miners are rewarded with 12.5 bitcoins(at the time of writing this article; this reward will get reduced by half its current value with time) and a small transaction fee.

URL PARSER: The URL parsing functions focus on splitting a URL string into its components, or on combining URL components into a URL string.

IMPLEMENTATION

The primary ways to create a cryptocurrency, none of which is fast and easy. Here’s how each of them works:

Create a New Blockchain Creating a new blockchain from scratch takes substantial coding skills and is, by far, the most difficult way to create a cryptocurrency. There are online courses that help walk you through the process, but they assume a certain level of pre-existing knowledge. Even then, you might not walk away with everything you need to go and create a new blockchain.

Mining of block: Blocks are mined by the miner on the network and as a result the block gets added to the blockchain if it passes the proof of work. Miner on his/her part gets 1 coin as a reward for giving the computational power to solve the underlying problem.

Display of blockchain: We have created a function that will display the entire blockchain. It will also serve as a check to see if the nodes are connected or not and whether everything is being done in a harmony, moreover it can also serve as the way to see the consensus at play.

Consensus algorithm: For your blockchain to operate smoothly the participating nodes must agree on which transactions should be considered legitimate and added to the block. Consensus mechanisms are the protocols that do just that. There are plenty to choose from for the best fit for your business objectives.

For your blockchain to operate smoothly the participating nodes must agree on which transactions should be considered legitimate and added to the block. Consensus mechanisms are the protocols that do just that. There are plenty to choose from for the best fit for your business objectives.

Step 3. Creating the Nodes

If you imagine a blockchain as a wall, nodes are the bricks it consists of. A node is an Internet-connected device supporting a blockchain by performing various tasks, from storing the data to verifying and processing transactions. Blockchains depend on nodes for efficiency, support, and security.

  1. What are they going to be in terms of permissions: private, public, or hybrid?
  2. Will they be hosted on the cloud, on premise or both?Select and acquire necessary hardware details, such as processors, memory, disk size, etc.
  3. Pick a base operating system (most common choices would be Ubuntu, Windows, Red Hat, Debian, CentOS, or Fedora)

Step 4. Establish your blockchain’s internal architecture

Tread carefully as some of the parameters can not be changed once the blockchain platform is already running. It’s a good idea to take your time and really think through the following:

● Permissions (define who can access the data, perform transactions and validate them, i.e. create new blocks) ● Address formats (decide what your blockchain addresses will look like) ● Key formats (decide on the format of the keys that will be generating the signatures for the transactions) ● Asset issuance (establish the rules for creating and listing all asset units) ● Asset re-issuance (establish the rules for creating more units of the open assets) ● Key management (develop a system to store and protect the private keys granting the blockchain access) ● Multi Signatures (define amount of keys your blockchain will require to validate a transaction ) ● Atomic swaps (plan for the smart contracts enabling the exchange of different cryptocurrencies without a trusted third party) ● Parameters (estimate maximum block size, rewards for block mining, transaction limits, etc.) ● Native assets (define the rules of a native currency issued in a blockchain) ● Block signatures (define how the blockchain participants creating blocks will be required to sign them) ● Hand-shaking (establish the rules of how the nodes will identify themselves when connecting to each other)

Step 5. Adding Transactions : Mentioning the sender and receiver and the amount of coins to be sent. Moreover the miner Will be getting 1 coin as a reward for mining.

Step 6. Take care of APIs:

Make sure to check whether the blockchain platform of your choice provides the pre-built APIs since not all of them do. Even if your platform doesn’t come with those, not to worry: there are a lot of reliable blockchain API providers out there.

Step 7: Design the Interface (Admin and User)

Communication is the key and a well-thought-out interface ensures a smooth communication between your blockchain and its participants.

Here are the things to consider at this stage:

  1. Web, mail and FTP servers
  2. External databases
  3. Postman API

SCREENSHOTS AND EXPLANATION

Genesis Block being created

Design

Mining a Block

Design

Visualization of BlockChain

Design

Adding a Transaction

Design

Checking the validity of BlockChain

Design

Mining by other users

Design


Setup

# install requirements
pip3 install -r requirements.txt

# setup nodes
python3 run.py 5001
python3 run.py 5002
python3 run.py 5003

# connect the nodes
curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5002"]
}' "http://localhost:5001/connect_node"

curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5003"]
}' "http://localhost:5001/connect_node"

curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5001"]
}' "http://localhost:5002/connect_node"

curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5003"]
}' "http://localhost:5002/connect_node"

curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5002"]
}' "http://localhost:5003/connect_node"

curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5001"]
}' "http://localhost:5003/connect_node"

curl -X POST -H "Content-Type: application/json" -d '{
 "nodes": ["http://127.0.0.1:5000"]
}' "http://localhost:5001/nodes/register"

# add some transactions
curl -X POST -H "Content-Type: application/json" -d '{
 "sender": "your-adress",
 "receiver": "someone-other-address",
 "amount": some_amount
}' "http://localhost:5001/add_transaction"

# mine a new block
curl -X GET http://localhost:5002/mine_block

# get the full blockchain
curl -X GET http://localhost:5003/get_chain

#check the validity of blockchain
curl -X GET http://localhost:5002/is_valid

# Replacing the chain by the longest chain if needed
curl -X GET http://localhost:5001/replace_chain

REFERENCES

[1]https://www.investopedia.com/articles/forex/091013/future-cryptocurrency.asp

[2]https://www.researchgate.net/publication/349505421_Non-Functional_Requirements_for_Blockchain_ Challenges_and_New_Directions

[3]https://medium.com/evan-network/six-core-requirements-you-should-consider-in-choosing-the-a-block chain-technology-e4fce36a1e

[4]https://docs.python.org/3/library/urllib.parse.html

[5]https://flask.palletsprojects.com/en/2.0.x/

[6]https://learning.postman.com/docs/developer/intro-api/