0% found this document useful (0 votes)
23 views

Hyperledger Fabric

Uploaded by

Poornima S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Hyperledger Fabric

Uploaded by

Poornima S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Hyperledger Fabric

Poornima S
SIES/IT
Famous Blockchain Frameworks

● Some of the most popular Blockchain frameworks include the


following

Ethereum
Hyperledger
R3 Corda
Quick Comparison
● Ethereum
○ Permissionless and generic Blockchain platform
○ Governed by Ethereum developers
○ Mining based on Proof of Work (POW)
○ Consensus approached at Ledger level
● Hyperledger
○ Modular and permissioned platform
○ Governed by Linux foundation
○ Multiple consensus approaches - at transaction level
● R3 Corda
○ Specialized distributed and permissioned ledger platform
○ Governed by R3
○ Specific consensus at transaction level
Hyper Ledger
● Introduced by Linux foundation, Hyperledger is an open source,
modular architecture targeted at businesses that aim to
streamline their process leveraging blockchain technology.

As Ethereum is an open and distributed platform where it


is impossible to hide a transaction from anyone, on the other
hand, hyperledger gives this flexibility.
Characteristics of HL Fabric
Ledger tracks all of the asset transactions and records state changes of the
asset
Hyperledger Fabric Network

Channel 1 Channel 2 Channel 3


World State World State World State

Ledger Ledger Ledger

Org_1 Org_2 Org_3

Org_4 Org_5
Organization

- Membership Service Providers (MSP) : Identity management of


members
- Administrators : To manage the members (enroll, remove etc.)
- Users : Typically applications connecting to the blockchain
network
- Peers : Hosting the chaincode and storing the ledger
- Orderers (optional) : Ordering of transactions
Each organization has an ID and a network can have multiple
participating organizations
X

L2 L2

A C2 B

L1 L1

Apps
Channel 1

D C

L1 L1
• Nodes A,B,C, D are
connected to a private
channel (subnet)

• Nodes B, C, E are other


private subnet channel

• Nodes B, C part of both


subnets

• Each subnet maintain


their ledger of their
transactions done in their
channel and reveal their
policies in private among
them
Image courtesy: NPTEL

Entities involved
Hyperledger - Tools and Frameworks

DLT and smart BC tool for digital identity


contract engine.

only project supply chain management


powered with a
smart contract
engine
Hyperledger Fabric system
Flow of Transactions

Endorse Order Validate

Client sends the The orderer simply orders The peers validate the
transaction proposal to the transactions, puts them transactions. (Check for double
endorser. The endorsers into blocks and sends it to spending, enforcement of the
return results with their all the peers to be endorsement policy etc.)
signatures. The client validated. It does not have
checks if the endorsement to look at the transactions.
policy is being satisfied. If
yes, it sends the
transaction to the orderer.
HL Fabric Transactions workflow
Modular Architecture of Hyperledger Fabric

Courtesy: IBM
Hyperledger Tools
Setup prerequisites

Recommended to set up on a linux based system

- Git https://git-scm.com/downloads
- CURL https://curl.se/download.html
- Docker Engine https://docs.docker.com/engine/install/
- NodeJS (recommend to use nvm (Node Version Manager))
- Docker Compose (version 1.29.2)
- Go
- Python 2.7 / 3.6

>> sudo groupadd docker To bypass using sudo every time while using docker
>> sudo usermod -aG docker $USER REQUIRED TO DO
Installing Hyperledger Fabric

Determine a location on your machine where you want to place the fabric-
samples repository and enter that directory in a terminal window.

>> mkdir fabric

>> cd fabric

>> curl -sSL https://bit.ly/2ysbOFE | bash -s -- <fabric_version> <fabric-ca_version>

Example:

>> curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.2.4 1.5.2

(Recommended to install 2.2.4)

>> export PATH=<path to download location>/fabric-samples/bin:$PATH


Starting the test network with CAs

>> cd fabric-samples/test-network

>> ./network.sh up -ca

The script will start containers for each member of the test-network namely:

- orderer
- peer0.org1.example.com
- peer0.org2.example.com
- ca_org1
- ca_org2
- ca_orderer
- cli
Creating a channel and deploying chaincode

>> ./network.sh createChannel -ca

● Creates a channel with name "mychannel"

>> ./network.sh createChannel -c <channel name> -ca

● To create a channel with a custom name


Deploying chain-code

>> ./network.sh -ccn <chain-code-name> –ccp <path-to-chaincode> -ccl


<chaincode-language>
● To deploy chaincode

Example:
>> ./network.sh -ccn basic –ccp ../asset-transfer-basic/chaincode-javascript -
ccl javascript

Other optional arguments:


● -ccep : To specify the endorsement policy
Running an application to invoke the chaincode

Example: Go to the asset-transfer-basic/application-javascript directory

The wallet directory stores the crypto material for a user issued by a CA. The CA is respawned
every time we do ./network.sh up.

Before running app.js

- Remove the wallet directory before running app.js.


- Run >> npm install

To run the app.js file : >> node app.js


Other examples of interest

● asset-transfer-events

While deploying the chaincode for this example set the -ccep flag to
“OR(‘Org1MSP.peer’, ‘Org2MSP.peer’)”

Example on how to use event listeners


Demo – Build your First Network

● Fabric samples: http:/ / hyperledger-fabric.readthedocs.io/ en/ release1.1/ samples.html


● Build network: http:/ / hyperledger-fabric.readthedocs.io/ en/ release1.1/ build_network.html
● Exercise: Install and instantiate marbles chaincode, and run application on the network you
created
References

- Endorsement policies — hyperledger-fabricdocs main documentation


- Private data — hyperledger-fabricdocs main documentation
- Private Data — hyperledger-fabricdocs main documentation - Implicit private data
- Hyperledger Fabric SDK for Node.js Interface: Network - BlockEventListeners
- Hyperledger Fabric SDK for Node.js Interface: Contract - ContractEventListeners

NPTEL links:

- https://youtu.be/4ujj5knD3pg?si=joLsrcNJDv1l7EMk : Fabric Membership and Identity Management


- https://youtu.be/xjliVltyLRk?si=IRReh8BBsUDSnWm- : Fabric Components details
- https://youtu.be/nBXr7dLXAbE?si=x4vaXCHnM_nLyOGs : Fabric Transaction flow

You might also like