CHAPTER 1: Introduction to Blockchain


Let us assume, Harry has bank account in Nepal and he wants to transfer $10,000 to Paul, who has his bank account in US. Harry asks the third trusted party and sends $10,000 to that party to transfer in Paul’s account in US. Now, the third trusted party takes some fees and transfers the remaining amount ($9990) to the bank account of Paul.
This transfer process takes about 2 to 3 days in total.
Here, I have highlighted the main problems seen while transferring money through the traditional way which is now solved by blockchain.
Blockchain:
- Transfers money without trusted entity.
- Transfers money faster than traditional way. (Immediately)
- Transfers money in cheaper way.

- The transfer process is clearly visible to everyone on the network.
- Everyone can decide if this transaction is valid or invalid.
First of all, let us assume there are four nodes in a network A, B, C and D, on which transaction takes place.
Let us say, for example, A has altogether 15$. This amount will be added in a block as shown in the above figure. This is the first block of a blockchain which is called a genesis block.
Now, A transfers $10 to B which is also recorded in the next block. Thereafter, B takes some money and transfers the remaining $7 to D. This transaction will also be added in the ledger as shown above.
Finally, D transfers $3 to C. Likewise, this will also be recorded in the block. All the transactions are clearly visible by each and every associated member in the network so that anyone can decide whether the transaction is valid or not. Now, let us assume, A tries to transfer $20 to C. There comes a question that A only had $15 specified to the network. Everyone can decide that this is not a valid transaction. Hence, this transaction will not be added in the ledger.
Distributed Open Ledger:
- Anyone can have the copy of the ledger.
- Everyone should have the same version of the ledger.
- Ledger is public and open.
- Ledger is distributed and essentially exists on every node.
- This distributed open ledger removes dependency on the third party.
Miners:
The role of miners is to validate transactions and add into the ledger.

If B tries to transfer money to D, this is not valid because only C and A are the miners in the network.
Miners have the copy of the transactions and the first miner does the transaction.
Hence,
- Blockchain consist of a chain of transactions that everyone on the network can see and validate.
- This chain of transactions is distributed across the network. Nodes have copies of the transactions with the same version.
Blockchain – Beyond the Definition:
Now, let us get the real concept of the inside of the blockchain. For this, we need to know about the hashing and hash function.
Hashing:

Hashing is taking input of any length and producing an output of fixed length.
In the above figure, we can see that ‘Hi’ is an input while
‘3639efcd08abb273b1619e82e78c29a7df02c1051b1820e99fc395dcaa3326b8’ is an output.
If we add only one character to this input ‘Hii’, the output becomes
‘487c6d1bbf24bda571430711f69783e8c12a17a1069684174a0ade88a2bf8eae’.
In terms of blockchain, transactions are taken as an input.

Properties of Hash Function:
- A small change in input produces big change in the output.
- No matter how many times you enter the same input, you get the same output.
- The hash function should be able to return the hash of an input quickly.
- It is impossible to get the input data based on the output hash.
- Each input will have its own unique hash.

We will talk in detail about the history of blockchain later. For now, only this is sufficient.

Blocks consist of:
- Data.
- Hash.
- Hash of previous blocks
- Data:
- Data stored inside blockchain depends on the type of the blockchain.
For example,

- Hash:
- Hash is like a fingerprint.
- Hash is always unique.
Once a block is created, its hash is calculated. Changing something inside the block will cause the hash to change. Hence, if we want to know about the changes inside the block, hash plays an important role.
- Hash of previous block:
This technique creates chain of blocks.

Block 1 is the first block in the network. It does not contain previous block hash. This is called Genesis Block.

Block 1 contains information about hash i.e. 528F. It does not have information about previous hash since this is the first block in the network. Likewise, Block 2 contains information of hash i.e. 649 C as well as information of its previous hash. Additionally, Block 3 contains hash: 34T5 and previous hash: 649C.
Now, if someone tries to change hash of block 2 (from 649C to 965R), then this makes all blocks in the network invalid because block 3 has records of previous hash. So, 1 invalid means all the blocks are invalid in the network.
However, only hashing is not sufficient to prevent tampering (damage).
Computers these days are very fast. They can calculate 1000s of hashes per second. We can recalculate all the hashes of other blocks to make the block chain valid again. Hence, to solve this, blockchain has a special function called Proof of Work.
Proof of Work:
Proof of Work is a mechanism that slows down the creation of new blocks.
For Bitcoin:
It takes 10 minutes: to calculate the required proof of work and add a new block to the chain.
Hence, security of blockchain comes with
- Hashing
- Proof of Work.
- Block chain is distributed (hence secure, since block chain uses peer to peer network).

If anyone joins the network, he gets full copy of the blockchain. The node can verify if this is valid or not.
Types of Block Chain:

Features of Blockchain:
- Distributed (Many copies of the ledger).
- Decentralized (No single point of control).
- Trustless (cannot be corrupted).
- Faster (than traditional system).
- Secured (everyone is aware of the data).
- Consensus based (Group of participants decide).