Blockchain

Blockchain Tutorial | Beginner&039s Guide to Blockchain Technology | Edureka

The growth of Bitcoin and Blockchain technology has been so rapid, that even those who haven’t heard of cryptocurrency or know about its working, are looking to invest and explore this field. This Blockchain tutorial blog will essentially provide you with all the fundamental knowledge you need regarding Bitcoin and Blockchain in the following sequence:

  1. Issues with the current Banking System
  2. How Blockchain solves these issues
  3. What is Blockchain and Bitcoin
  4. Features of Blockchain
  5. Use Case
  6. Demo: Implementing Digital Banking using Blockchain

Blockchain technology and the crypto-currencies have today become a parallel platform where people have started performing their standard transactions. Now, if a new system is slowly replacing an existing system then there must be some issues with the current system. We will begin this Blockchain tutorial blog by understanding the problems of the current banking system.

Issues with Current Banking System:

Any existing system will have some issues. Let us look at some of the most commonly faced issues with the Banking system:

  • High Transaction Fees

Let’s look at an example to understand this issue better:

The issue of Transaction Fees - Blockchain Tutorial - EdurekaHere Peter has only $500 in his account. He initiates 2 transactions simultaneously to Adam for $400 and Mary for $500. Normally this transaction would not go through as he doesn’t have sufficient balance of $900 in his account. However, by duplicating or falsifying the digital token associated with every digital transaction, he can complete these transactions without the needed balance. This operation is known as Double Spending.

  • Net Frauds and Account Hacking

    Example of Double Spending - Blockhain Tutorial - Edureka

In India, the number of fraud cases related to credit/debit cards and Internet banking was 14,824 for the year 2016. The net amount involved in these frauds was Rs 77.79 crore, of which Rs 21 crore was from internet frauds and Rs 41.64 crore was from ATM/debit card-related frauds.

  • Financial Crisis and Crashes

    Net Frauds - blockchain Tutorial - edureka

Imagine giving all your saving to someone you trust only to know that they have gone and lost it somewhere else. That’s what happened in the 2007-08 when Banks and Investment Organisations had borrowed heavily and lent it as subprime mortgages to people who could not even pay back these loans. This in turn lead to one of the greatest financial crisis ever seen and was estimated to have caused losses close to $11 Trillion ($11,000,000,000,000) worldwide. This was just one of the most popular examples, how often have we heard of Banks and Financial service companies crash due to internal frauds? The whole third-party system is something that is built on blind trust on the middle man.

We have seen some of the most common problems faced by everyone. Wouldn’t it be great to have a system that overcame these problems and provided us with a That’s exactly what Blockchain Technology does.

Let us now try to understand how Blockchain and Bitcoins solve these issues as the next part of this Blockchain tutorial blog.

Find out our Blockchain Training in Top Cities/Countries

IndiaOther Cities/CountriesBangaloreNew YorkHyderabadUKKeralaUSAChennaiCanadaMumbaiAustraliaPuneSingapore

How does Blockchain solve these issues?

Below are some of the ways through which the Blockchain technology tackles the above mentioned issues:

  • Decentralized System

The Blockchain system follows a decentralized approach when compared to banks and financial organisations which are controlled and governed by Central or Federal Authorities. Here, everyone who is part of the system becomes equally responsible for the growth and downfall of the system. Rather than one single entity holding the power, everyone who is involved with the system holds some power.

  • Public Ledgers

The ledger which holds the details of all transactions which happen on the Blockchain, is open and completely accessible to everyone who is associated with the system. Once you join the Blockchain network, then you can download the complete list of transaction since its initiation. Even though the complete ledger is publicly accessible, the details of the people involved in the transactions remains completely anonymous.

  • Verification of Every Individual Transaction

Every single transaction is verified by cross-checking the ledger and the validation signal of the transaction is sent after a few minutes. Through the usage of several complex encryption and hashing algorithm, the issue of double spending is eliminated.

  • Low or No Transaction Fees

The transaction fees are usually not applicable but certain variants of Blockchain do implement certain minimal transactions fees. These transaction fees are however relatively quite less when compared to the fees implied by banks and other financial organisations. If a transaction needs to be completed on priority then an additional transaction fees can be added by the user so as to have the transaction verified on priority.

Now that we have spoken about the issues with the current existing system and understood how the Blockchain technology overcomes these challenges, I am quite sure you must have got some understanding of the Blockchain System.

At this point you might still be wondering as to what exactly is the Blockchain and Bitcoin. So let’s try to understand these important concepts in the next part of this Blockchain tutorial.

What is Blockchain and Bitcoin?

Before we go on to understand what is Blockchain, it important that you understand what is Bitcoin:

Financial crisis - Blockchain Tutorial - edureka

Bitcoins are a crypto-currency and digital payment system invented by an unknown programmer, or a group of programmers, under the name Satoshi Nakamoto. That means they can be used like a usual currency, but don’t physically exist like dollar bills. They are an online currency which can be used to buy things. These are similar to “digital cash” that exist as bits on people’s computers. Bitcoins exist only in the cloud, like Paypal, Citrus or Paytm. Even though they are virtual, rather than physical, they are used like cash when transferred between people through the web.

The Bitcoin system is peer-to-peer network based and transactions take place between users directly, without an intermediary. These transactions are verified by network nodes and recorded in a public distributed ledger called a Blockchain. Since the system works without a central repository or single administrator, Bitcoin is called the first decentralized digital currency.

Bitcoin production makes them a unique currency. Unlike normal currencies, Bitcoins cannot be created as needed. Only 21 Million Bitcoins can be created, of with 17 million have already been created. Bitcoin get created whenever a block containing valid transactions is added to the Blockchain. This is the only means for creating Bitcoins and through various mathematical and encryption algorithms we ensure no fake Bitcoins are created or circulated. Let us now understand more Blockchain.

What is Blockchain?

Bitcoin - Blockchain Tutorial - Edureka

If Chandler sends some bitcoins to Joey, that transaction will have three pieces of information:

  • Joey’s bitcoin address.(Joey’s Public key)
  • The amount of bitcoins that Chandler is sending to Joey.
  • Chandler’s bitcoin address.(Chandler’s Public key)

Now all this data along with an encrypted digital signature is sent through the network for verification. The Digital signature is again a hash value achieved by the combination of the Chandler’s bitcoin address and the amount he is sending to joey. This digital signature is encrypted by the private key. Once this data is received by a miner who has to verify this transaction, there are 2 process he does simultaneously:

  1. He takes all the un-encrypted data like transaction amount and public keys of both Joey and Chandler, and feeds it to a hash algorithm to get a hash value which we shall call Hash1
  2. He takes the digital signature and decrypts it using chandler’s public key to get a hash value which we will call as Hash2

If both Hash1 and Hash2 are the same then it means that this a valid transaction.

Distributed Ledger and P2P Network

Blockchain - Blockchain Tutorial -EdurekaYou might be wondering if everyone equally owns the ledger, who adds blocks to the Blockchain? How can people trust this person?

For this, we have the concept of proof of work. It is basically like solving a very big puzzle. It requires lots of computational effort. This work is done by people in the Bitcoin network we call miners. The work of these miners is to verify the transactions and solve a complex mathematical puzzle associated with the block being created. The difficulty of the problem is adjusted so that on average a block is solved in 10 minutes. Miners search for a specific nonce(mathematical value) which gives the desired hashwhich is predetermined. The current difficulty level is such that you need to try about 20.6 quadrillion nonce to get the correct hash.

Each block has a hash value which is the combination of the previous block’s final hash, transaction data’s hash value and the nonce. The final resulting hash for the block must start with a specified number of trailing zeroes. It is this computation to find the nonce which satisfies the condition that makes mining so computationally expensive.

So the person who finds this nonce is the successful miner and he/she can add their block to the blockchain. Through our P2P distributed network, he/she broadcasts their block and everyone verifies if hashes match, updates their blockchain and moves on to solving the next block immediately.

Incentives for Validation

Hash algorithm - Blockchain Tutorial - Edureka

The last step of a Bitcoin transaction is to giving a reward to the miner who has created the latest block. This rewards is provided by the Blockchain system for validating the transactions and maintaining the Blockchain. Currently the reward per block is 12.5 BTC (Rs 3,427,850/- or $ 53,390). This is the most interesting part of Bitcoin Mining.

Bitcoin incentives is the only way to generate new currency into the system and it is believed that by 2140, all 21 million bitcoins will be mined.

With this, I hope you now have more understanding and appreciation towards the Blockchain technology. Blockchain is much more than Bitcoin. Finance is just one of the many industries Blockchain aims to disrupt. Moving ahead with our Blockchain tutorial, let us now look at one such example of IBM and Maersk, to understand how the Supply Chain Industry is disrupted by blockchain.

Blockchain Tutorial: Use Case

Maersk is a Danish business conglomerate with activities in the transport and logistics, and energy sectors. Maersk has been the largest container ship and supply vessel operator in the world since 1996. The company is based in Copenhagen, Denmark with subsidiaries and offices across 130 countries and around 88,000 employees.

IBM is an American multinational technology company mainly working on business solutions, security solutions and storage solutions since 1921

Business need:

Being a part of an extremely dynamic Supply Chain industry, tracking the slightest change is of highest priority for the client. They needed a solution that could enable them to complete the shipping process without having the delay in paper work. A solution that would be able to bring together all the stakeholders of the system and provide a real-time status on the shipment.

Challenges:

Today, 90% of the goods in global trade are carried by the shipping industry. This supply chain is flowed by the complexity and sheer volume of point-to-point communication. These communications are across a loosely coupled web of land transportation providers .freight forwarders, customs, brokers, government’s ports and ocean carriers processing. Documents and information for a container shipment is estimated to cost more than twice that of the actual physical transportation.

Solution:

IBM and Maersk are addressing this problem with a distributed permission platform accessible by the supply chain ecosystem designed to exchange event data and handled document workflows.

Digital Signature - Blockchain Tutorial - Edureka

Merck and IBM are employing Blockchain technology to create a global tamper proof system by the digitizing trade workflow and tracking shipments end-to-end. This eliminates frictions including costly point-to-point communications. The collaboration will launch with potential ability to track millions of container journeys per year and integrate with customs authorities on selected trade lanes.

Results:

  • Provided a secure Data Exchange platform for all the stakeholders involved in the supply chain system.
  • Established a Tamper proof repository to store all the documents involved as part of the process.
  • Regular shipping events help reduce significant Delays and Frauds, saving Billions of dollars annually.
  • Reduced the barrier between trade organisations thereby increasing worldwide GDP by 3%.
  • Helped increase the overall trade volume by 12%.

This is how Blockchain technology helped Maersk and has been helping many other companies worldwide. Finally as part of this Blockchain tutorial, we will look at a demo as to how you set up a private autonomous Blockchain on your system.

Blockchain Tutorial: Demo

We will implement a digital bank using Ethereum Blockchain. Ethereum is an open-source, public, blockchain-based distributed computing platform. The systems will allow us to:

  1. Make a cryptocurrency with a fixed market supply and tokens to represent real world asset values.
  2. Create an autonomous private Blockchain with rules on spending money.
  3. Mine for a new Ether by validating transactions.

The demo can be divided into 4 steps:

  1. Cloning Geth Code
  2. Creating a Genesis Block
  3. Making Rules for our Blockchain
  4. Validating & Mining Ether

Step 1: Cloning Geth Code:

geth is the command line interface for running a full ethereum node implemented in Go. By installing and running geth, you can take part in the ethereum frontier live network and

  • Mine real ether
  • Transfer funds between addresses
  • Create contracts and send transactions
  • Explore block history

Cloning the geth repository from github. To do this, open a new terminal and execute the following command:

$ git clone https://github.com/ethereum/go-ethereum

Distributed Ledger - Blockchain Tutorial - Edureka

After you have successfully cloned the file from github, we need to branch the latest version of geth.

$ cd go-ethereum $ git tag

Proof of work - Blockchain Tutorial - Edureka

IBM Maersk use Case - Blockchain Tutorial - Edureka

$ git checkout tags/v1.6.7 -b EdurekaEthereumV1.6.7 $ git branch

git command - Blockchain Tutorial -Edureka

$ make all

Step 2: Creating Genesis Block

A genesis block is the first block of a block chain. Changing the genesis block is a way to definitively fork yourself away from the bitcoin blockchain, i.e, start a new network with it’s own separate history. To create the genesis file, execute the following commands:

$ cd go-ethereum $ mkdir genesis $ cd genesis $ gedit genesis.json

cd command - Blockchain Tutorial -Edureka Step 3 : Making Rules for our Blockchain

The rules for our Blockchain will be included in the genesis.json file we have created. Add the following code in your genesis.json file:

{ { “config”:{ “chainId”: 123, “homesteadBlock”: 0, “eip155Block”: 0, “eip158Block”: 0, }, “nonce”: “0x3”, “timestamp”: “0x0”, “parentHash”: “0x0000000000000000000000000000000000000000000000000000”, “extraData”: “0x0”, “gasLimit”: “0x4c4b40”, “difficulty”: :0x400″, “mixhash”: “0x0000000000000000000000000000000000000000000000000000”, “coinbase”: “0x000000000000000000000000000000000”, “alloc”:{ } }

nonce: A 64-bit hash, which proves, combined with the mix-hash, that a sufficient amount of computation has been carried out on this block.

timestamp: A scalar value equal to the reasonable output of Unix time() function at this block inception.

mixhash: A 256-bit hash which proves, combined with the nonce, that a sufficient amount of computation has been carried out on this block.

difficulty: A scalar value corresponding to the difficulty level applied during the nonce discovering of block.

alloc: Allows defining a list of pre-filled wallets. It’s an Ethereum specific functionality to handle the “Ether pre-sale” period.

parentHash: The Keccak 256-bit hash of the entire parent block header (including its nonce and mixhash).

extraData: An optional free, but max. 32-byte long space to conserve smart things for ethernity.

gasLimit: A scalar value equal to the current chain-wide limit of Gas expenditure per block.

coinbase: The very first transaction included in the block by the miners.

Now we need to initialize the blockchain. You can do that by using the following command:

$ /home/edureka/go-ethereum/build/bin/geth -datadir ~/ethereum/net3 init genesis/genesis3.json

git tags- Blockchain Tutorial -Edureka

Now that we have initialized the blockchain, it’s time that we give geth control access to it. Execute the following command to start the geth console:

$ /home/edureka/go-ethereum/build/bin/geth -datadir ~/ethereum/net3/ -networkid 3 console

branch - Blockchain Tutorial -Edureka

Step 4: Validating & Mining Ether.

In the Geth console, execute the following command:

personal.newAccount() : it creates a new account as part of your blockchain which has a specific wallet attached to it.

making genesis file - Blockchain Tutorial -Edureka eth.accounts: It helps you check the various accounts which are part of your blockchain.

eth.blockNumber(): this helps you to identify the number of blocks that are part of your blockchain.

miner.start(): this function is used to start the mining process.

Geth console - Blockchain Tutorial -Edureka

Below you can see the mining application running:

persona.newAccount() - Blockchain Tutorial - Edureka miner.stop(): it stops the mining process

eth.accounts - Blockchain Tutorial -Edureka eth.blockNumber(): executing this command after the mining process tells you at which block number you are at after performing the mining operation eth.getBalance: (“account number”): this command is used to check the ether balance in the specified account

miner.start() - Blockchain Tutorial -Edureka exit: Exit the geth console.

With this we have successfully mined ether and completed our Banking Demo. This brings us to the end of this blog. I hope you liked this Blockchain tutorial blog. This was the first blog of the Blockchain tutorial series. This Blockchain tutorial blog will be followed by my next blog, which will focus on Blockchain technologies and Bitcoin Transactions. Do read them as well to learn more about Blockchain.

If you wish to learn Blockchain and build a career in Blockchain Technologies, then check out our Blockchain Training in Hyderabad which comes with instructor-led live training and real-life project experience. This training will help you understand Blockchain in depth and help you achieve mastery over the subject.

Got a question for us? Please mention it in the comments section and we will get back to you.

Related Articles

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker