KEMBAR78
Blockchain Lab Manual | PDF | Computer Science | Computer Engineering
0% found this document useful (0 votes)
56 views40 pages

Blockchain Lab Manual

Uploaded by

Atharva Shelke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views40 pages

Blockchain Lab Manual

Uploaded by

Atharva Shelke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Suman Educational Trust’s

DILKAP RESEARCH INSTITUTE OF ENGINEERING AND


MANAGEMENT STUDIES
Village Mamdapur, Post Neral, Tal: -Karjat, Dist Raigad – 410101,

DEPARTMENT OF
COMPUTER ENGINEERING

LABORATORY MANUAL

COURSE: BLOCKCHAIN LAB

COURSE CODE: CSDL7022

Semester-VII

Subject In - Charge
PROF. ARCHANA MATE
Practical List

Subject: Blockchain Semester: VII

Sr. No Experiment Name Page No

1 Cryptography in Blockchain, Merkle root tree hash

2 Creating Smart Contract using Solidity and Remix IDE.

3 Creating Transactions using Solidity and Remix IDE

4 Embedding wallet and transaction using Solidity

5 Blockchain platform ethereum using Geth.

6 Blockchain platform Ganache.

7 Case Study on Hyperledger

8 Case Study on Other Blockchain platforms.

9 Creating a blockchain Application


EXPERIMENT NO: 1
Name of the Student:
Roll No.
Date of Practical Performed: Staff Signature with Date
& Marks

Aim: Cryptography in Blockchain, Merkle root tree hash


Theory:

Merkle Tree in Blockchain


The hash tree, also known as a Merkle tree, is a tree in which each leaf node is labeled with the
cryptographic hash of a data block, and each non-leaf node is labeled with the cryptographic
hash of its child nodes' labels. The majority of hash tree implementations are binary (each node
has two child nodes), but they can also have many more child nodes.

What Is a Merkle Tree?

 Merkle trees, also known as Binary hash trees, are a prevalent sort of data structure in
computer science.

 In bitcoin and other crypto currencies, they're used to encrypt blockchain data more
efficiently and securely.

 It's a mathematical data structure made up of hashes of various data blocks that summarize all
the transactions in a block.

 It also enables quick and secure content verification across big datasets and verifies the
consistency and content of the data.
Merkle Tree Structure

Structure of Merkle tree

1. A blockchain can potentially have thousands of blocks with thousands of transactions in


each block. Therefore, memory space and computing power are two main challenges.
2. It would be optimal to use as little data as possible for verifying transactions, which can
reduce CPU processing and provide better security, and this is exactly what Merkle trees offer.
3. In a Merkle tree, transactions are grouped into pairs. The hash is computed for each pair and
this is stored in the parent node. Now the parent nodes are grouped into pairs and their hash is
stored one level up in the tree. This continues till the root of the tree. The different types of
nodes in a Merkle tree are:
 Root node: The root of the Merkle tree is known as the Merkle root and this Merkle root is
stored in the header of the block. 
 Leaf node: The leaf nodes contain the hash values of transaction data. Each transaction in
the block has its data hashed and then this hash value (also known as transaction ID) is
stored in leaf nodes. 
 Non-leaf node: The non-leaf nodes contain the hash value of their respective children.
These are also called intermediate nodes because they contain the intermediate hash values
and the hash process continues till the root of the tree. 
4. Bitcoin uses the SHA-256 hash function to hash transaction data continuously till the Merkle
root is obtained.
5. Further, a Merkle tree is binary in nature. This means that the number of leaf nodes needs
to be even for the Merkle tree to be constructed properly. In case there is an odd number of
leaf nodes, the tree duplicates the last hash and makes the number of leaf nodes even.
Cryptographic Hash Functions

 A hash function maps any type of arbitrary data of any length to a fixed-size output. It is
commonly used in cryptography since it is a cryptographic function. 

 They are efficient and are well-known for one property: they are irreversible. It's a one-way
function that's only meant to work in one direction.

 Some of the Hash families available are Message Direct (MD), Secure Hash Function (SHF),
and RIPE Message Direct (RIPEMD).

Now, take an example, if you use the SHA256 hash algorithm and pass 101Blockchains as input,
you will get the following output.

fbffd63a60374a31aa9811cbc80b577e23925a5874e86a17f712bab874f33ac9

In conclusion, these are the following key properties of the hash function:

 Deterministic

 Pre-Image Resistant

 Computationally Efficient

 Cannot be Reversed Engineered

 Collision Resistant

Working of Merkle Trees

A Merkle tree totals all transactions in a block and generates a digital fingerprint of the entire set
of operations, allowing the user to verify whether it includes a transaction in the block.
 Merkle trees are made by hashing pairs of nodes repeatedly until only one hash remains; this
hash is known as the Merkle Root or the Root Hash. 

 They're built from the bottom, using Transaction IDs, which are hashes of individual
transactions.

 Each non-leaf node is a hash of its previous hash, and every leaf node is a hash of
transactional data.

Now, look at a little example of a Merkle Tree in Blockchain to help you understand the
concept.

Consider the following scenario: A, B, C, and D are four transactions, all executed on the same
block. Each transaction is then hashed, leaving you with:

 Hash A

 Hash B

 Hash C

 Hash D

The hashes are paired together, resulting in:

 Hash AB

and

 Hash CD

And therefore, your Merkle Root is formed by combining these two hashes: Hash ABCD.
In reality, a Merkle Tree is much more complicated (especially when each transaction ID is 64
characters long). Still, this example helps you have a good overview of how the algorithms work
and why they are so effective.

Benefits of Merkle Tree in Blockchain

Merkle trees provide four significant advantages -

 Validate the data's integrity: It can be used to validate the data's integrity effectively. 

 Takes little disk space: Compared to other data structures, the Merkle tree takes up very little
disk space.

 Tiny information across networks: Merkle trees can be broken down into small pieces of data
for verification. 

 Efficient Verification: The data format is efficient, and verifying the data's integrity takes
only a few moments.

Why Is It Essential to Blockchain?

Think of a blockchain without Merkle Trees to get a sense of how vital they are for blockchain
technology. Let’s have one of Bitcoin because its use of Merkle Trees is essential for the
cryptocurrency and easier to grasp.

 If Bitcoin didn't include Merkle Trees, per se, every node on the network would have to retain
a complete copy of every single Bitcoin transaction ever made. One can imagine how much
information that would be.

 Any authentication request on Bitcoin would require an enormous amount of data to be


transferred over the network: therefore, you'll need to validate the data on your own. 

 To confirm that there were no modifications, a computer used for validation would need a lot
of computing power to compare ledgers. 

Merkle Trees are a solution to this issue. They hash records in accounting, thereby separating the
proof of data from the data itself.

 Proving that giving tiny amounts of information across the network is all that is required for a
transaction to be valid.

 Furthermore, it enables you to demonstrate that both ledger variations are identical in terms of
nominal computer power and network bandwidth. 
EXPERIMENT NO: 2
Name of the Student:
Roll No.
Date of Practical Performed: Staff Signature with Date

& Marks

Aim: Creating Smart Contract using Solidity and Remix IDE

Theory:

Remix IDE

Remix IDE, is a no-setup tool with a GUI for developing smart contracts. Used by experts and
beginners alike, Remix will get you going in double time. Remix plays well with other tools and
allows for a simple deployment process to the chain of your choice. Remix is famous for our
visual debugger. Remix is the place everyone comes to learn Ethereum.

Step 1 — Setup Remix IDE

1.1 — The first step is setting up the Remix IDE. Remix IDE is a browser-based development
environment for Smart Contracts. The IDE provides several plugins and compilers for different

solidity versions.

To launch the Remix IDE, visit http://remix.ethereum.org; you will see the page below, which

might be different depending on when you are reading this article.


Remix Home Page

Notice that in the image above, you can see “Featured Plugins” because the Remix IDE is built

with a pluggable architecture, which means that all the operations are performed using plugins.

1.2 — The next thing to do is to enable the Solidity compiler plugins, as shown below.

Enable Plugins
1c — After enabling the plugin, click on the “Solidity compiler” button, and select the compiler

configuration shown in the image below.

Compiler Configuration

It is noteworthy to mention that compiler versions in Solidity are tricky to work with, and the

advice is that you should try not to work with the most recent version. Interestingly, you will find
some legacy projects still running on older solidity versions, and this is okay. In summary, try to

stick with the version you see in a particular tutorial if you are a beginner.

In the image above, you will see that we are working with compiler version 0.8.1, which might

not be the recent version. Also, you can set the compiler version in the Solidity source file by

using the “pragma” line at the beginning of the file. The Pragma line is just a way of telling the

compiler the version you are working with.

Now that everything is all set let’s write our first smart contract in the next step.

Step 2 — Write your first Smart Contract

Like any other programming language, the first step is creating a project file for the language.

Here, you will create a file titled, “MyFirstSmartContract.sol”. The “sol” file extension stands for
Solidity, just like “py” is for Python.

See the images below to create this file in the Remix IDE.

2.1 — Create Workspace


Create workspace

2.2 — Create the file; MyFirstSmartContract.sol


Create a file

2.3 — Write the code


// SPDX-License-Identifier: GPL-3.0pragma solidity ^0.8.1;contract MyFirstContract {
string public myString = “Hello World”;
}
EXPERIMENT NO: 3
Name of the Student:
Roll No.
Date of Practical Performed: Staff Signature with Date

& Marks

Aim: Write a Smart Contract using Solidity and Remix IDE

Theory:

Solidity:

Solidity is a brand-new programming language created by the Ethereum which is the second-
largest market of cryptocurrency by capitalization, released in the year 2015 led by Christian
Reitwiessner. Some key features of solidity are listed below:

Solidity is a high-level programming language designed for implementing smart contracts.

It is statically-typed object-oriented(contract-oriented) language.


Solidity is highly influenced by Python, C++, and JavaScript which runs on the Ethereum Virtual
Machine(EVM).
Solidity supports complex user-defined programming, libraries and inheritance.
Solidity is primary language for blockchains running platforms.
Solidity can be used to creating contracts like voting, blind auctions, crowdfunding, multi-
signature wallets, etc.

Ethereum
Ethereum is a decentralized open-source platform based on blockchain domain, used to run smart
contracts i.e. applications that execute the program exactly as it was programmed without the
possibility of any fraud, interference from a third party, censorship, or downtime. It serves a
platform for nearly 2,60,000 different cryptocurrencies. Ether is a cryptocurrency generated by
ethereum miners, used to reward for the computations performed to secure the blockchain.

Ethereum Virtual Machine (EVM)


Ethereum Virtual Machine abbreviated as EVM is a runtime environment for executing smart
contracts in ethereum. It focuses widely on providing security and execution of untrusted code
using an international network of public nodes. EVM is specialized to prevent Denial-of-service
attack and confirms that the program does not have any access to each other’s state, also ensures
that the communication is established without any potential interference.
Smart Contract
Smart contracts are high-level program codes that are compiled to EVM byte code and deployed
to the ethereum blockchain for further execution. It allows us to perform credible transactions
without any interference of the third party, these transactions are trackable and irreversible.
Languages used to write smart contracts are Solidity (a language library with similarities to C
and JavaScript), Serpent (similar to Python, but deprecated), LLL (a low-level Lisp-like
language), and Mutan (Go-based, but deprecated).

// Solidity program to
// demonstrate how to
// write a smart contract
pragma solidity >= 0.4.16 < 0.7.0;

// Defining a contract
contract Test
{

// Declaring state variables


uint public var1;
uint public var2;
uint public sum;

// Defining public function


// that sets the value of
// the state variable
function set(uint x, uint y) public
{
var1 = x;
var2=y;
sum=var1+var2;
}

// Defining function to
// print the sum of
// state variables
function get(
) public view returns (uint) {
return sum;
}
}
Output
EXPERIMENT NO: 4
Name of the Student:
Roll No.

Date of Practical Performed: Staff Signature with Date


& Marks

Aim: . Embedding wallet and transaction using Solidity


Theory:

1. Get an Ethereum node client.

There are several Ethereum node clients. A popular one is go-ethereum, a client written in Go.
Download it and install it.

Ethereum, as other cryptocurrencies do, has different versions of the blockchain with different
parameters. There are essentially two blockchains: the main official blockchain and a test
blockchain. The main blockchain never undoes operations once they are confirmed. Since some
operations require money, the main blockchain is not ideal for testing. The test blockchain, on
the other hand, is much less strict about forks and changes. It is also simpler to mine "Ether",
Ethereum's currency.

We could use the test network for our example here. However, running a client node for any of
the public networks is problematic for one reason: to be able to start doing transactions, the client
must first verify all previous transactions in the blockchain. That means that bootstrapping a new
client node takes quite a bit of time. Fortunately, there is an alternative: we can create a new,
pristine private Ethereum blockchain to run our tests. To do so, run go-ethereum using the
following command line:

./geth --rpc --nat none --dev

2. Create a new Ethereum account to mine some Ether

The geth command can also be used to interact with a running client. Launch an interactive
console connected to the running client:

/geth attach
ipc:/var/folders/ts/7xznj_p13xb7_5th3w6yjmjm0000gn/T/ethereum_dev_mode/geth.ipc

The IPC file mentioned in the command can be found in the output from running the node in our
first step. Look for the line that reads:

IPC endpoint opened:


/var/folders/ts/7xznj_p13xb7_5th3w6yjmjm0000gn/T/ethereum_dev_mode/geth.ipc
Now in the Geth console type:

personal.newAccount()

After hitting ENTER a prompt will appear requesting a passphrase. This is the passphrase that
will be used to perform any operations using this account. You can think of this as the passphrase
required to decrypt the private-key used to sign Ethereum transactions. Do not leave the prompt
empty, choose a simple passphrase for testing instead. A new Ethereum address will be returned
by the function. If at any point you forget this address, you can list accounts by
inspecting personal.listAccounts (it's a variable, not a function, so don't add () at the end).

The geth console is a JavaScript interpreter.

3. Start mining some Ether

Now it's time to add some Ether to our new account. Ether is required to perform operations in
the Ethereum blockchain, so it is necessary to perform this step. Ether can be gathered in two
ways: by receiving it from another account or by mining it. Since this is a private network, we
will need to mine it. Don't worry, the private network is by default configured to be able to mine
Ether easily. Let's do it:

miner.setEtherbase(personal.listAccounts[0]) // Hit ENTER


miner.start() // Hit ENTER

Now wait a few seconds (or minutes depending on your hardware) and then confirm you have
some Ether in your account:

eth.getBalance(personal.listAccounts[0]) // Hit ENTER

4. Compile and deploy our Login contract

To simplify the process of compiling and deploying contracts, we will use truffle. Truffle is a
development framework for Ethereum, simplifying many common tasks. Install it:

npm install -g truffle

Before using truffle to deploy contracts, it is necessary to "unlock" our account in our Ethereum
node client. Unlocking is the process of decrypting the private-key and holding it in memory
using the passphrase used to create it. This allows any client libraries (such as Truffle)
connecting to the node to make operations on behalf of the unlocked account. Go to
the geth console and type:

personal.unlockAccount(personal.listAccounts[0]) // Hit ENTER

Now switch to the solidity directory of our sample application. Edit the truffle.js file and set your
newly created address as the from key. Then run:
truffle migrate

The migrate command compiles and deploys the contracts to the Ethereum network on behalf of
the account set in truffle.js. As a result you will get the address of the newly deployed contract.
Take note of it.

5. Install an Ethereum wallet

Ethereum wallets are convenient interfaces for users to interact with the Ethereum network.
Sending and receiving Ether, deploying contracts or making calls to them are all operations
usually supported by wallets. Mist is the official Ethereum wallet. Download it and install it.

Once installed, we will need to tell Mist to connect to our private network rather than the public
main or test networks. To do this, run Mist from the command line like so:

./Ethereum\ Wallet --rpc


/var/folders/ts/7xznj_p13xb7_5th3w6yjmjm0000gn/T/ethereum_dev_mode/geth.ipc

The IPC file is the same file used by the geth console and can be gathered from the geth output
logs.

6. Tell the Ethereum wallet of the contract

Many contracts live in the Ethereum network. Wallets need to know a contract's address and
interface before being able to interact with them. Let's tell Mist about our Login contract. Go
to Contracts -> Watch Contract (top right, then bottom left).
Complete the fields as follows:

 Name: Login
 Contract Address:
 JSON Interface: the abi from Login.json. For convenience it is pasted below. Copy and
paste it in Mist.

[ { "constant": false, "inputs": [ { "name": "challenge", "type": "string" } ], "name": "login",


"outputs": [], "payable": false, "type": "function" }, { "anonymous": false, "inputs": [ {
"indexed": false, "name": "sender", "type": "address" }, { "indexed": false, "name": "challenge",
"type": "string" } ], "name": "LoginAttempt", "type": "event" } ]

As a test, now try to send some Ether to the contract: Contracts -> Login -> Transfer
Ether & Tokens. Send 1 Ether or any other amount less than your balance. You will need to
provide the passphrase for your account.
7. Deploy the backend.

Go to the backend folder and run:

npm install
node app.js

8. Serve the frontend

Go to the frontend folder and run:

npm install -g static-serve


static-serve

You may use any other simple static HTTP server such as Python's Simple HTTP Server. If you
do so, make sure to serve the app in port 9080. This is important due to CORS.

9. Test everything together!

Open your browser at http://localhost:9080. Now attempt to login by putting your Ethereum
address in the input field. A challenge text will be generated. Go to the Mist (Ethereum Wallet)
and go to the Login contract. To the right you will see "WRITE TO CONTRACT". Select
the login function and paste the challenge in the text fill that appears there. Then click
on Execute. Input your passphrase and send the transaction.
Now switch back to the login page. After a few seconds the login will be completed and a
welcome message will appear. Voilà!

This example shows how a typical Ethereum user can use his existing Ethereum account to login
to any third party website supporting Ethereum. And all of this is done without a central server.
Although authentication is not performed by the owner of the website, there is no central
authority validating the user: it is the Ethereum network that does so.
EXPERIMENT NO: 5
Name of the Student:
Roll No.

Date of Practical Performed: Staff Signature with Date


& Marks

Aim: Blockchain platform ethereum using Geth.


Theory:

What is Geth?
Geth(Go Ethereum) may refer to a Golang implementation of Ethereum blockchain in the form
of a standalone client software. Geth is a command line interface for running Ethereum nodes
implemented in Go Language. Using Geth you can join Ethereum network, transfer ether
between accounts or even mine ethers.
Geth Ethereum is the command-line interface for implementing an Ethereum node in Google’s
Go programming language. Geth serves as a node in the blockchain that helps the user to mine
Ether and creates software that runs on Ethereum Virtual Machine. Geth helps to mine real ether,
create contracts, make transactions, transfer funds between addresses, etc. Geth is supported on
almost all operating systems like Linux, macOS, and Windows.

Steps to configure go-ethereum on our local machine.


Step 1. a) Open Terminal
b) Take clone of go-ethereum by following command
git clone https://github.com/ethereum/go-ethereum
Step 2. Download go compiler and installation step
a) wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
b) sudo tar -xvf go1.7.4.linux-amd64.tar.gz
c) sudo mv go /usr/local
d) Create a .go directory at home. (It is easy to install the necessary packages without admin
privilege) mkdir ~/.go
e) Set up the following environment variables
GOROOT=/usr/local/go
GOPATH=~/.go
PATH=$PATH:$GOROOT/bin:$GOPATH/bin
f) Update the go command
sudo update-alternatives --install "/usr/bin/go" "go" "/usr/local/go/bin/go" 0
sudo update-alternatives --set go /usr/local/go/bin/go
g) Test the golang version
h) sudo apt-get install -y build-essential golang
Step 3. Last step for check , is go-ethereum configure successfully, by running following
command – cd go-ethereum make geth

Features of Go-Ethereum:
● As the name suggests, Geth only deals with Ethereum.

● It allows for solo mining or in a pool.

● The software has CPU mining but requires GPU mining software to produce ETH

efficiently. You would therefore need to pair it up with an appropriate program.

● Each GPU will need 1 to 2 GB of RAM.

● It can be installed on Windows, Linux, Android, or iOS.

● There are no fees when you are in solo mining mode. Costs from mining in a pool vary

depending on the pool.

Conclusion: Implementation of Creating a blockchain platform using Go-Ethereum was done

significantly.
Output:
EXPERIMENT NO: 6
Name of the Student:
Roll No.
Date of Practical Performed: Staff Signature with Date

& Marks

Aim: Study and Use of Blockchain platform Ganache.


Theory:

Ganache

Ganache is a private Ethereum blockchain environment that allows to you emulate the Ethereum
blockchain so that you can interact with smart contracts in your own private blockchain.
Ganache forms part of the Truffle Suite, a set of developer tools that allows users to recreate
blockchain environments locally and test smart contracts. Smart contract execution on the
Ethereum blockchain is very different from other types of software.

Features of Ganache:
● Displays blockchain log output
● Provides advanced mining control
● Built-in block explorer
● Ethereum blockchain environment
● Ganache has a desktop application as well as a command-line tool

Steps to install ganache:

● You may download Ganache from the following URL:


https://truffleframework.com/ganache

● When you open the installation URL given above, it automatically detects your
machine’s OS and directs you to the appropriate binary installation.

● Locate the “Ganache-2.0.0.dmg” in your Downloads folder and double-click on it to


install Ganache. Upon successful installation, the following screen will appear −

● Drag Ganache icon to the Application folder. Now, Ganache is available as an


application on your Mac.
● Now locate Ganache in your Application folder and double-click on its icon to start
Ganache.
● Click QUICKSTART to start Ganache.

Conclusion:
Hence studied and implemented Ganache.

Output:
EXPERIMENT NO: 7

Name of the Student:

Roll No.

Date of Practical Performed: Staff Signature with Date

& Marks

Aim: Case study on Hyperledger

Theory:

What is Hyperledger Fabric?

Hyperledger Fabric is a permissioned distributed ledger framework that enables the development
of enterprise-grade applications and solutions.

To ensure it is easy to integrate and develop, the design is kept versatile and modular. Clearly,
this also means that it can fit into different use cases and provide a unique way to solve
consensus within a network without the need to sacrifice performance or privacy.

At the core, the first thing that makes Hyperledger Fabric so useful is its key characteristics,
including permissioned nature, security, and high-performance. The code for Hyperledger Fabric
is written in Go, Java, JavaScript, Python, REST, and so on. Another version called Hyperledger
Fabric 2.0 is also out and available for everyone to use.

Hyperledger Fabric is an open-source platform for building distributed ledger solutions, with a
modular architecture that delivers high degrees of confidentiality, flexibility, resiliency, and
scalability. This enables solutions developed with fabric to be adapted for any industry. This is a
private and confidential blockchain framework managed by the Linux Foundation.

Hyperledger Fabric is a permissioned blockchain framework, with a modular architecture (plug-


and-play). It leverages container technology to host smart contract (Chaincode) which contains
application logic.
Before going to each component in detail let us see a high-level transaction flow and basic
components involved.
Hyperledger Fabric Basic Transaction Flow

Here when clients submit the transaction proposal through the Fabric SDK, this proposal is sent
to all Endorsing Peers. These endorsing peers check the transaction verifies and executes and
generate the Read and Write set as output. Now, this response is again sent to the client. The
client collects all responses from all endorsing peers and send them to Order. Now, ordered sees
all transactions and orders them in ascending order and form a block. Now, this block is sent to
all committers which checks the transaction and add a new block in their own copy of the ledger.
Since you are aware of basic terms and workflow, let’s see blockchain’s main components.
Later, we will see the transaction flow in much more detail.

Fabric consists of below major components

Membership Service Provider (MSP)


Client
Peer

Orderer
Membership Service Provider (MSP)
The membership service provider (MSP), is a component that defines the rules in which,
identities are validated, authenticated, and allowed access to a network. The MSP manages user
IDs and authenticates clients who want to join the network. This includes providing credentials
for these clients to propose transactions. The MSP makes use of a Certificate Authority, which is
a pluggable interface that verifies and revokes user certificates upon confirmed identity. The
default interface used for the MSP is the Fabric-CA API. However, organizations can implement
an External Certificate Authority of their choice. As a result, a single Hyperledger Fabric
network can be controlled by multiple MSPs, where each organization brings its own favorite.
There are two types of MSPs.

Local MSP: It defines users (Clients) and nodes (peers orderers). It defines who has
administrative or participatory rights at that level.

Channel MSP: It defines administrative and participatory rights at the channel level.

Client
Clients are applications that act on behalf of a person to propose transactions on the network.
The client uses a Fabric SDK in order to communicate with the network. The client
communicates with the SDK in order to Read or Write the data in a Fabric blockchain and an in-
state DB. Even the client is issued with a certificate from the CA authority in order to make sure
that a valid client has initiated the transaction over the network.

Nodes
A “Node” is only a logical function in the sense that multiple nodes of different types can run on
the same physical server. What counts is how nodes are grouped in “trust domains” and
associated with logical entities that control them.

There are three types of nodes:

Client: A client that submits an actual transaction-invocation to the endorsers, and broadcasts
transaction-proposals to ordering service. In short, clients communicate with both peers and the
ordering service

Peer: A node that commits transactions and maintains the state and a copy of the ledger. A peer
receives ordered state updates in the form of blocks from the ordering service and maintains the
state and the ledger. Besides, peers can have a special endorser role. The special function of an
endorsing peer occurs with respect to a particular chaincode and consists in endorsing a
transaction before it is committed.

Ordering-service-node or Orderer: a node running the communication service that implements


a delivery guarantee, such as atomic or total order broadcast.

Types of Peers

Endorsing Peer: Endorsing peers is a special type of committing peers who have an additional
role to endorse a transaction. They endorse the transaction request which comes from the client.
Each endorsing peer possesses the copy of smart contract installed and a ledger. The main
function of Endorser is to simulate the transaction. It is executed based on the smart contract on
the personal copy of the ledger and generates the Read/Write sets which are sent to Client.
Though during simulation, the transaction is not committed to the ledger.

Committing Peer: Peers who commit the block which is received from the Ordering service, in
their own copy of the blockchain. This block contains the list of transactions where committing
peer to validate each transaction and mark it as either valid or invalid and commits to the block.
All transaction either valid or invalid are all committed to blockchain for future audit purpose.

Anchor Peer: As Fabric network can extend across multiple organization, we need some peers
to have communication across an organization. Not all peers can do this, but these are special
peers who are only authorized to do so which are nothing but Anchor peer. The anchor peers are
defined in Channel configuration.

Leading Peer: Leader peers are those who communicate or disseminate messages from Ordering
service to other peers in the same organization. These peers use Gossip protocol to make sure
that every peer receives the message. Leading peers cannot communicate across an organization.
If any Leading peer is not responding or is out of network, then we can select a leading peer from
available peer based on voting or randomly choose one.

Channels

A fabric network can have multiple channels. Channels allow organizations to utilize the same
network while maintaining separation between multiple blockchains. Only members(peers) of
the channels are allowed to see the transaction created by any member in a channel. In other
words, channels partition the network in order to allow transaction visibility for stakeholders
only. Only the members of the channel are involved in consensus, while other members of the
network do not see the transactions on the channel. The peer can maintain multiple ledgers. And
peer can be connected to multiple channels.
The configuration of the channel is maintained by configtx.yaml file. Using this file we generate
channel.tx file and then create a channel using it. Chaincode is installed on all participating peers
in a channel, whereas chaincode is instantiated on a channel. A channel contains all the
configurations of communication between peers. It holds the list of peers along with who are
endorsing, anchor, leader peers. When a client communicates with the network using SDK, the
SDK first gets a list of all endorsing peers to which the transaction request needs to send. Using
this list the SDK sends transaction requests to peers. Peers that do participate in multiple
channels simulate and commit transactions to different ledgers. Orderers are also a part of
channels.

Features of Hyperledger Fabric


This blockchain project is generally known for its modularity and versatility. It encourages a
collaborative approach for developing blockchain technologies through the community process,
with intellectual property rights that promote open development and the adoption of key
standards over time. Let’s have a look at its major features.

Private and Permissioned– Rather than an open, permissionless system that allows unknown
identities to participate in the network, the members of a Hyperledger Fabric network enroll
through an MSP (Membership Service Provider), which is completely trusted.

Privacy– Unlike other networks, where privacy is not a top concern, this blockchain project
supports networks where privacy (using channels) is a crucial operational requirement.

Smart Contract Functionality– Hyperledger Fabric supports smart contracts written in


chaincode, that can be implemented in several programming languages; for now, it is
implemented in Go and Node. It possesses an open smart contract model that allows the
flexibility to achieve any desired solution model.
Consensus Mechanism– It features a flexible endorsement model for achieving consensus. It is
designed to allow network starters to choose a consensus mechanism that best represents the
relationships that exist between participants across required organizations.

Moreover, it offers the ability to create channels, allowing a group of participants to create a
separate ledger of transactions. It provides data sharing on a need-to-know basis by leveraging
private data ‘collections.’
EXPERIMENT NO: 8
Name of the Student:
Roll No.

Date of Practical Performed: Staff Signature with Date


& Marks

Aim: Case Study on Corda

What is Corda?
Corda is distributed ledger software for recording and processing shared data such as contracts,
designed to implement the vision contained in this document. Corda supports smart contracts,
matching the definition of Clack, Bakshi, Braine 4; our smart contract is an agreement whose
execution is both automatable by computer code working with human input and control, and
whose rights and obligations, as expressed in legal prose, are legally enforceable.

Features of Corda
Corda’s design was initially driven by the needs of regulated financial institutions but turns out
to be far more broadly applicable. It is heavily inspired by blockchain systems, but without the
design choices that make traditional blockchains inappropriate for the execution of real-world
business transactions. Our fundamental building block is a “state object”, representing a specific
instance of a specific agreement, which may be thought of as representing a real-world contract
or section of a contract. We use the terms ‘agreement’ and ‘contract’ interchangeably in this
paper. This stands in contrast to systems where the data over which participants must reach
consensus is the state of an entire ledger or the state of an entire virtual machine. Corda provides
three main tools to achieve global distributed consensus:
• Smart contract logic which specifies constraints that ensure state transitions are valid
according to pre-agreed rules, described in contract code as part of CorDapps. • Uniqueness and
timestamping services known as notary pools to order transactions temporally and eliminate
conflicts.
• A unique component called the flow framework which simplifies the process of writing
complex multi-step protocols between multiple mutually distrusting parties across the internet
What Makes Corda Blockchain Framework Different?

Privacy: Privacy is a critical focus for any distributed ledger technology system. It is because
your data is bound to be distributed across multiple nodes and servers belonging to different
business entities. In R3’s Corda, the only parties who have access to the details of a transaction
are those involved in the transaction and those who need to assure themselves of transaction
provenance.
It means two or more participants can transact with one another, sharing only necessary
information between them. This is in stark contrast to public blockchain or few private
blockchain frameworks - broadcasting the transaction or its details across the entire network. The
privacy feature of the Corda blockchain framework is what enterprises and businesses would
want. Like other comrade frameworks, Corda does not include any gossip protocols which
broadcasts all transactions to the network.
Identity: Identification of different parties in the DLT system over a permissioned blockchain
becomes a core criterion to build a closed network of the system among known participants. In
R3 Corda, parties have assurance over the identity of members in the blockchain network.
Identity is a very important feature for a global decentralized ledger where you are unaware of
other participants. It is made possible with KYC requirements of all participants across the
network and the core identity framework which enables Corda to assign a single user profile to
any legal entity, be it an organization or an individual.
Consensus: Consensus is a technique through which organizations over a distributed and
decentralized network come on to an agreement over the transactions happening between them.
It is an important concept to identify malpractices and maintain the integrity of any blockchain
network, no matter if its public or permissioned.
Transactions in Corda are confirmed through a process of consensus using a variety of
algorithms, including Byzantine Fault Tolerant algorithms. Just like any other blockchain, the
unique features a Corda network can support multiple different consensus pools using different
algorithms enabling its clients with a pluggable consensus model based on their requirement.
Contracts: Smart contracts and program files embedding the business logic, rules validation are
part of any business being run among different organizations over a blockchain-based distributed
system. In R3’s Corda, transactions are processed by having each participant execute the same
code deterministically to verify the proposed updates to the ledger.
Just like Ethereum, the languages you can use are high-level and productive, like Java and
Kotlin, rather than obscure ones like Solidity. The validation function of the CorDapp (Corda
Distributed Applications) contract code only needs the validation chain of each associated
transaction.
No Block, But Chain: Corda’s functionality relies on the UTXO input/output model, which is
very similar to the transaction system used in traditional blockchains such as Bitcoin. However,
the storage and verification do not end up into a chain of blocks like other enterprise blockchain
frameworks, e.g., Hyperledger Fabric that bundles up a set of transactions between ‘n’ number of
participants over the channel into a block-based on different criteria. Corda links transaction in a
cryptographically linked (chained) chain to the transactions it depends on and not to a previous
block of some other set of transactions.

Conclusion:
Successfully concluded a study on Corda.

You might also like