​Blockchain is the most sought after topic in the tech world. But how did it all start? Well, the popularity of the cryptocurrency put the spotlight on the Blockchain technology. Nearly, everyone’s heard the word ‘Blockchain’ but very few know the fundamental technology behind them. It is not very easy to understand this technology; there are various videos and tutorials that you might find online but you will find it in bits and pieces. Here, let’s take a step-by-step look at how the Blockchain works and its different terms and technologies.
Basics of Blockchain

A Blockchain is like a diary of codes that cannot be forged. It allows transactions, mostly monetarily (for now), to be exchanged without a central authority or a third party vendor. It is an immutable, sequential chain of records called blocks which contain transactions, files or any other data. 

These blocks are chained together using hashes. To simply put it, the hash function takes an input value and from that derives an output. The input value could include any data such as numbers, files, etc. For instance, if you input “hello world”, the output received would be something like “5eb63bbbe01eed093cb22bb8f5acdc3”.
https://learncryptography.com/hash-functions/what-are-hash-functions
To keep a track of these Blockchains, ever user has a ledger. A ledger is a digital file that keeps a record of all the transactions that take place. This file is not stored in one central location or in one particular server; it is distributed across the world via a network of private computers that are both, storing the data and executing computations.
https://en.wikipedia.org/wiki/Ledger
Each of these computers represents a node of the Blockchain network and has a copy of the ledger file. Basically, every time a transaction occurs, it needs to be approved by the nodes, each of whom checks the validity. If the nodes determine that the transaction is valid, only then it is written into a block. For example, if you only had one entry, all the other computers will have the original hash and hence, the change would not occur.     
https://en.bitcoinwiki.org/wiki/Node
To perform transactions on the Blockchain, you need a wallet. This is a program that allows you to store and exchange your information. A wallet is a string of alphanumeric code such as 13fjgkh4457slkprrtyu938903b4n56yhuiklp which appears within the Blockchain as transactions take place. Only the number of the wallet is visible and the address of each wallet is also a public key. But to carry out a transaction, you also need a private key, which is also called the digital signature. This key is a string of private numbers that need to be kept a secret but if someone wants to send the message; it must contain the private key and the public key.

How are these keys created? Cryptographic keys (a string of numbers and alphabets) are made by key generators or keygens.
The Blockchain is programmed with a large set of rules which are called protocols. These protocols ensure that the network runs the way the creators have intended for it to run even though it isn’t centrally controlled by them.

Proof of Work is a system that requires some work from the service requester, usually meaning processing time by a computer, for example, the hash. A Proof of Work algorithm (PoW) is how new Blocks are created or mined on the BlockchainThe goal of PoW is to discover a number which solves a problem. The number must be difficult to find but easy to verify—computationally speaking—by anyone on the network.
This proof of work is carried out by special nodes called miners. These miners produce blocks by solving proof of work problems. When the electronic consensus of nodes approves a block produced by the miner, then the miner is rewarded with coins. For instance, in October 2017, Bitcoin miners got 12.5 Bitcoins per block. There is also a transaction fee that is paid to them by the users. Since, bitcoin has a huge amount of transactions happening, the transaction fees have sky rocketed.

Principles of Blockchain

Distributed database

The database is the Blockchain and its each node that has access to the whole Blockchain, that is that there are many computers and nodes that regulate the information instead of a singular database. Every node is able to validate the records of the Blockchain. It is architecturally decentralized as there is no one or several points of failure to bring down Blockchain; however, the nodes of a Blockchain are logically centralized but there are certain actions programmed into it.

Peer-to-Peer (P2P) transmission

As we’ve determined earlier, there is no third party involved and hence, the communication is happening directly with peers through a central node. Each node stores the information about what is happening and then passes it on to the adjacent nodes. This is how the information spreads through the whole network.

Transparency yet Anonymity

Anyone inspecting the Blockchain is capable of seeing every transaction and its hash value. But at the same time they are anonymous unless they give their identification to others. All that the user can see is a record of transactions that have taken place between Blockchain addresses.

Why is it almost impossible to fake a block?

The reason that faking a block is almost impossible is that the validity of the block and, by extension, its inclusion into the Blockchain is determined by an electronic consensus of nodes. There are thousands of these nodes, scattered all over the world, and as a consequence capturing the network would require a computer with impossible power.
 
What do you need to make a Blockchain?

  • Install Python 3.6+ (along with pip)
  • Install Flask
  • HTTP client

Final Code: https://github.com/dvf/Blockchain

Step 1: Open your favourite text editor or IDE, and create a new file called Blockchain.py. Create an initial empty list and another to store transactions. A block will have an index, a timestamp, a list of transactions, a proof and a hash of the previous block.

 Step 2: Use the Python Flask Framework which is a micro-framework that makes it easy to map endpoints to Python functions. This is the step where one starts interacting with the Blockchain.

Step 3: Use plain old cURL or Postman to interact with the API. Fire up the server, and then try mining a block. Create a new transaction.

Step 4: Now that we’ve got a basic Blockchain, you can accept transactions and mine new blocks. Blockchains need to be decentralised and hence, we will need to implement the Consensus Algorithm, if we want more than one node in the network.
You can refer to https://github.com/dvf/Blockchain in case you get lost.
Blockchain is the next step in technology that will rapidly change the face of economies, governments and record-keeping. Now that we’ve understood how Blockchain works, let’s take a look at how it is advantageous for the user:

  • There is no third party involved. It’s a centralised system, where you complete control of your own value.
  • The cost to perform the value of transaction is low which in turn makes it the most go to technology for micro payments.
  • Transparency is guaranteed as anyone can verify any transaction made on the Blockchain.
  • One can build decentralised applications that would be able to manage information and transfer the value in a fast and secured fashion.

Future of Blockchain

In reference to a report by CBInsights, “Fast-forward to today: the total market capitalization of cryptocurrencies hovers around $150B (with a single Bitcoin trading for upwards of $5,000), Walmart and Pfizer have completed successful Blockchain pilots in food safety and medicine tracking, and initial coin offerings (ICOs) have exploded in popularity, closing on $2B+ in funding in 2017 alone.
 
Politically, Blockchain technology has fostered a renewed examination of today’s highly centralized web, and reignited conversations around currency and value, digital governance, and the fundamental structures and rails of our modern internet.”
Also, as of October 2017, “there have been 42 equity investment deals in 2017 alone, totalling $327 mln. The most active investor is a Japanese services firm SBI Holding, with stakes in eight Blockchain firms. A digital powerhouse Google is the second-most active investor, with stakes in the Bitcoin wallet company Blockchain and Ripple, a company that is working on Blockchain-based money transferring system.”
https://www.cbinsights.com/research/report/blockchain-trends-opportunities/
The Blockchain technology is still in its infancy. New tools are being developed to improve the Blockchain security while offering a broader range of features, tools and services.
 

Categories: Uncategorized