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

Module 7

Uploaded by

Adarsh Goud
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)
16 views

Module 7

Uploaded by

Adarsh Goud
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/ 105

Course Outline

1. Cryptocurrency and Blockchain


2. Delving into Blockchain
3. Bitcoin and Blockchain
4. Bitcoin Mining
5. Ethereum
6. Setting up a Private Blockchain Environment Using Ethereum Platform
7. Hyperledger
8. Setting up a Development Program Using Hyperledger Composer
9. Creating and Deploying a Private Blockchain on Multichain
10. Prospects of Blockchain
© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.
Hyperledger

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Agenda

At the end of this session, you will be able to:

 Define Hyperledger Blockchain


 Understand Hyperledger Consensus Algorithm
 Explain Hyperledger Iroha
 Identify Hyperledger Components
 Describe Setting up Channels, Policies and Chaincodes
 List Hyperledger Explorer Components
 Define Hyperledger Composer

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Blockchain

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Blockchain “
Let’s know more about the


Hyperledger Blockchain.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Business Network: Traditional Vs. Blockchain
Centralized or Distributed Ledger?
A distributed ledger is a network that records ownership through a shared registry.
Centralized Ledger Distributed Ledger

Business Network A: Business Network B:


The traditional view The Blockchain view

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Blockchain for Business

It's the mix of a common, unalterable record


An append-only Business terms
that streamline business procedures and distributed embedded in a
open new doors for advancement. system of records transaction
shared across database and
business executed with
Consensus in Blockchain is organized networks transactions
between individuals which wipes out
expensive dangers and wasteful aspects as
Ensuring All parties come
resources and change hands all through the appropriate to an agreement
business of Blockchain. visibility and if on the network
transactions are verified
secure, transaction
This enterprise-ready Blockchain platform authenticated unanimously
and verifiable
makes it easy to activate and manage a
secure business network across multiple Broader Participation, Lower Cost and Increased Efficiency
organizations.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


What is a Hyperledger?
Hyperledger (or Hyperledger project) is a cross-country collaborative effort to create Blockchain-based open standard
for distributed ledgers for globally conducted business transactions. The project has been started by Linux Foundation
and backed by technological, financial, banking and supply-chain companies world-wide.

The project aims to create an open-standard, public, decentralized public ledger based on the Blockchain technology
to advance world-wide business transactions processing in terms of cost-effectiveness, speed and traceability
On Feb 2, 2016, IBM committed the first 44K lines of code on GitHub.

Founding members of this initiative represent a diverse group of stakeholders:

• ABN AMRO • CME Group • Deutsche Börse • IBM • NEC Corp


• Accenture • ConsenSys Group • Intel • NTT Data
• ANZ Bank • Credits • Digital Asset • IntellectEU • R3
• Blockchain Ltd. • Depository Holdings • J.P. Morgan • State
• BNY Mellon Trust & Clearing • Fujitsu Ltd. • Red Hat • Street
• Calastone Corporation • Guardtime • Swift • Symbiont
• Cisco (DTCC) • Hitachi • VMware
• CLS • Wells Fargo

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Problems with Existing Blockchains
Characteristics Ethereum Hyperledger Fabric R3 Corda

Description of the • Specialized distributed ledger


• Generic Blockchain platform • Modular Blockchain platform
Platform platform for financial industry

Governance • Ethereum developers • Linux Foundation • R3

Mode of Operation • Permissionless, public or private • Permissioned or private or • orprivate


Permissioned or
• Mining based on the Proof of • Broad understanding of
• Specified understanding of
Work (PoW) consensus that allows multiple
Consensus consensus (i.e., notary nodes)
• Ledger level approaches
• Transaction level
• Transaction level
• Smart contract code (e.g.,
Kotlin, Java, etc.)
• Smart contract code (e.g., • Smart contract code (e.g., Go,
Smart Contracts • Smart legal contract (e.g., legal
Solidity) Java, etc.)
prose)

• None
• Ether
Currency • Currency and tokens via • None
• Tokens via smart contracts
chaincode
© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.
Goals of the Hyperledger
Where open-source teams build diverse approaches for business blockchain technology systems

</>

Creating enterprise- Providing neutral, Building technical Educating the public Promoting our
grade, open-source open and community- communities community of
distributed ledger driven infrastructures about the market communities
frameworks and code to develop blockchain opportunity for the
bases supported by and shared ledger blockchain technology taking a toolkit
technical and POCs, use cases, field approach with many
to support business business governance trials and platforms and
transactions deployments frameworks

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger: How It Works

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger: How It Works
Solution User : End us ers typi c ally Chaincode (Smar t Contr act):
i niti ate trans actions on a c hai n Auditor (s): Indivi duals or
Solution Pr ovider : Appli c ati on logi cs s tored and
network through appl ic ations made Organi zations that devel op organi zations wi th the permis s i on
exec uted on the bloc kc hai n
avai lable by s ol uti ons providers to interrogate trans ac tions and the
mobil e/web applic ations for
bl oc kc hain network
s oluti on us ers to acc ess Val i dating Node C Chaincode
chain networks. They own
either NV or Val idating node Validating Chainc ode Logic State
Node D
Public Tr ansactions: Chainc ode
Trans ac tions wi th i ts Non-validating
payl oad i n the c l ear Node Validating Chai nc ode
Node E Chaincode State: Chai nc odes ac c ess
Non-validating Node (NV): Cons truc ts i nternal s tate s torage through s tate APIs.
Blockchain Networ k: A c hai n network that States are c reated and updated by
trans ac tions and forwards them to vali dating
s ervi ces s oluti ons bui lt for a partic ular industry trans ac tions c alling c haincode functi ons
nodes. Peer nodes keep a c opy of al l transaction
Shar ed Ledger : Rec ords all trans actions across wi th the s tate ac c es sing logic
records s o that s oluti on providers can query
the bus ines s network
them loc al ly
Consensus: Trans ac tion validation and
Confidential Chaincode: Chainc odes
Membership Service (PKI) c ommi tment
that only predefi ned s ubs et of
Pr opr ietor s: Setup and
Re g. A ECA TCA TL S CA Validating val idators c an view and ex ec ute
defi ne the purpos e of a c hain
Node A
network. They are the
Registr ation Author ity (Re g. A): As s i gns regis tration us ername and pass word pai rs to s takehol ders of a network
network partic ipants . Thi s username/pass word pair wi ll be used to acquire enroll ment
c erti fic ate from ECA Validating
Enr ollment CA (ECA): Is s ues enrol lment c ertific ates (ECert) to network partic ipants that Node B
have already regi s tered wi th a members hi p servi ce. ECerts are l ong-term certifi cates us ed
to identify i ndividual enti ties partic ipating in one or more networks
Tr ansaction CA (TCA): Is sues trans ac tion certi ficates (TCerts ) to ECert owners . An infinite Confidential Tr ansactions:
number of TCerts c an be derived from eac h ECert. TCerts are us ed by network parti cipants trans ac tions where its payload is
to send trans ac tions enc rypted and i s onl y vis ible to
TLS CA: Is s ues TLS c erti fic ates to systems that trans mit mes sages i n a chain network. TLS s takehol ders of thi s trans action
c ertific ates are us ed to s ec ure the c ommunic ation channel between systems

Blockchain Network
© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.
Hyperledger Frameworks & Tools
Infrastructure
Technical, legal, marketing and
organizational ecosystems that
accelerate open development and Cloud Foundry Node.js Hyperledger Open Container
commercial adoption Initiative

Frameworks
Meaningfully differentiated approaches
to business blockchain frameworks Hyperledger Hyperledger
Hyperledger Hyperledger
developed by a growing community of Sawtooth Burrow
Indy Iroha
communities

Tools
Typically built for one framework and,
through common license and community Hyperledger Hyperledger Hyperledger
of communities approach, ported to other Composer Explorer Cello
frameworks

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Architecture
• Hyperledger reference architecture is aligned in three categories: Membership, Blockchain and Chaincode.
• These categories are a logical structure, not a physical depiction of partitioning of components into separate
processes, address spaces or (virtual) machines.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Membership
Membership Service Provider

• An abstraction of identity provider


• <MSP.id, MSP.sign, MSP.verify, MSP.validateid,
Membership
MSP.admin>
• governs application, endorser and orderer
Membership
identities
Services
• Used as building blocks for access control
Registration
frameworks
Identity
• at the system level (read/write access on
Management
system controls and channel creation)
Auditability
• at the channel level (read/write access)
• at the chaincode level (invocation access)
• Represents a consortium or a member

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Blockchain

Server REST API


Rule Execution
© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.
Chaincode
Chaincode is a piece of code that lets you interact with a network’s
shared ledger.
Whenever you invoke a transaction on the network, you are
effectively calling a function in a piece of chaincode that reads and
writes values to the ledger.
Chaincode services use Docker to host the chaincode.
Docker provides a secured, lightweight method to sandbox
chaincode execution.
Environment is a secured container, along with a set of signed base
images containing secure OS and chaincode language, runtime and
SDK images for Go Lang.
Additional programming languages can be enabled, if required.
Secure Registry Services ​enable Secured Docker Registry of base
Hyperledger images and custom images containing chaincodes.
© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.
Hyperledger Consensus Algorithm

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Consensus Algorithm “
Let’s learn about different consensus


algorithms for Hyperledger.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Consensus Algorithm

• Because different industries and regions may


run their own networks, different networks
might need to deploy different consensus
algorithms to fit their usage scenarios.

• Consensus algorithms under the


Hyperledger protocol must be pluggable,
allowing users to select the consensus
algorithm of their choice during deployment.

• The Hyperledger protocol will provide an


implementation of Byzantine Fault Tolerance
(BFT) in its initial release, using the PBFT
protocol.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Generalized Hyperledger Consensus Process Flow
Separating Transaction Endorsement from Consensus

End User

End User

End User

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Application Programming Interface

• Enroll
ECert • Request ECert

Enrollment certificate
(ECert) is the long-term
identity of a participant on
the blockchain network. Invokes chaincode txn
(signed with ECert)

Invokes chaincode txn


(signed with ECert)

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Application Programming Interface
API has the following categories:

Identity: Enrollment to get certificates or revoke a certificate


Address: The target and source of a transaction
Storage: An external store for files or documents
Event: Sub/pub events on the Blockchain

Transaction: The unit of execution on the ledger

Chaincode: The program running on the ledger


Blockchain: The content of the ledger
Network: Information about the Blockchain network

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Application Model

A Hyperledger application follows a Model View Control Blockchain (MVC-B)


architecture View Logic
• View Logic: Mobile or Web UI interacting with the control logic
• Control Logic: Coordinates among UI, Data Model and Hyperledger APIs to
drive transitions and the chaincode
• Data Model: Application Data Model manages off-chain data, including
documents and large files Control Data
• Blockchain Logic: Extensions of the Controller Logic and Data Model into Logic Model
the Blockchain realm. Controller Logic is enhanced by the chaincode, and
the Data Model is enhanced with transactions on the blockchain.

For example, a PaaS application using Node.js might have a web frontend user
Blockchain Logic
interface or a native mobile app with a backend model provided by a data
management service. The control logic may interact with one or more
chaincodes to process transactions on the blockchain. Chaincode Transactions

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Projects & Tools
Hyperledger Modular Umbrella Approach
Infrastructure
Technical, legal, marketing and
organizational ecosystems that
accelerate open development and
commercial adoption
Hyperledger Open Container
Cloud Foundry Node.js
Initiative

Frameworks
Meaningfully differentiated
Hyperledger Hyperledger Hyperledger Hyperledger Hyperledger
approaches to business blockchain
Indy Fabric Iroha Sawtooth Burrow
frameworks developed by a growing
community of communities

Tools
Typically built for one framework and, through common Hyperledger Hyperledger Hyperledger
license and community of communities approach, ported Composer Explorer Cello
to other frameworks

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Iroha

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Iroha “
Hyperledger Iroha features a simple
construction. Let’s have a look at the


Hyperledger Iroha.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Iroha
Iroha means "the basics" , "ABCs" or "the most basic element of all“.

• Hyperledger Iroha features a simple construction; this modern, domain-driven
C++ design emphasizes on mobile application development and a new chain-
based Byzantine Fault Tolerant consensus algorithm, called Sumeragi.


• Iroha is a distributed ledger project that was designed to be simple and easy to
incorporate into infrastructural projects requiring the distributed ledger
technology.

The goal of Iroha is to provide:


• An environment for C++ developers to contribute to the Hyperledger
• An infrastructure for mobile and web application support
• A framework to experiment with new APIs and consensus algorithms that could
potentially be incorporated into Fabric in future

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Why Hyperledger Iroha?


Currently, the Hyperledger project lacks an infrastructure project written in
C++, thus limiting the potential developers who can contribute.

Most important features of Iroha:


• Creation and management of custom complex assets, such as currencies or
indivisible rights, serial numbers, patents, etc.
• Management of user accounts
• Taxonomy of accounts based on domains or sub-ledgers in the system
• The system of rights and verification of user permissions for the execution of
transactions and queries in the system
• Validation of business rules for transactions and queries in the system

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sawtooth Lake
Sawtooth makes it easy to develop and deploy an application by providing a clear separation
between the application level and the core system level. It provides smart contract abstraction
that allows application developers to write contract logic in a language of their choice.

Sawtooth is written in Python and designed for use cases in many fields from IoT to Financials.

Sawtooth is built to solve the challenges of permissioned (private) networks. Clusters of


Sawtooth nodes can be easily deployed with separate permissioning.
Its core design allows applications to choose the transaction rules, permissioning and consensus
algorithms that support their unique business needs.

Sawtooth is an open-source project under the Hyperledger umbrella.

In Sawtooth, the data model and transaction language are implemented in a transaction family.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Why is Sawtooth Lake different?

Sawtooth keeps distributed ledgers distributed.

Sawtooth users are able to define their own custom “transaction family” with data models and
transaction languages tailored to their use cases.

Hyperledger Sawtooth supports creating and broadcasting events and allows applications to:
• Subscribe to events that occur in relation to the blockchain, such as a new block being
committed or switching to a new fork
• Subscribe to application specific events defined by a transaction family.
• Relay information about the execution of a transaction back to clients without storing that
data in state.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Tools in Hyperledger

Hyperledger Cello Hyperledger Composer Hyperledger Explorer


It aims to bring the on-demand “as- It is a collaboration tool for building It can view, invoke, deploy or query
a-service” deployment model to the blockchain business networks, blocks, transactions and associated
blockchain ecosystem to reduce the accelerating the development of data, network information,
effort required for creating, smart contracts and their chaincodes and transaction families,
managing and terminating deployment across a distributed as well as any other relevant
blockchains. ledger. information stored in the ledger.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Cello

Hyperledger Cello is a blockchain provision and operation system, which helps


manage blockchain networks.

• Hyperledger Cello is a blockchain module toolkit and one of the Hyperledger


projects hosted by the Linux Foundation.
• It aims to bring the on-demand “as-a-service” deployment model to the
blockchain ecosystem to reduce the effort required for creating, managing and
terminating blockchains.
• It maintains a pool of running blockchain networks on top of baremetals, Virtual
Clouds (e.g., virtual machines, vSphere Clouds, etc.) and container clusters (e.g.,
Docker, Swarm, Kubernetes, etc.).
• It helps check the system status, adjust the chain numbers, scale resources and
so on through dashboards.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Main Features of Cello
Manage the lifecycle of blockchains; e.g.,
create/start/stop/delete/keep health automatically

Support customized (e.g., size, consensus, etc.) blockchains


request; currently, they mainly support Hyperledger Fabric

Support native Docker host, Swarm or Kubernetes as worker


nodes; more supports on the way

Support heterogeneous architecture, e.g., X86, POWER and Z,


from baremetal servers to virtual machines

Extend with monitor, log, health and analytics features


by employing additional components

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Explorer
Hyperledger Explorer is a blockchain module designed to create a user-friendly web application.

It was initially contributed by IBM.

Designed to create a user-friendly web application, Hyperledger Blockchain Explorer can view, invoke,
deploy or query blocks, transactions and associated data, network information (name, status, list of
nodes, etc.), chain codes and transaction families, as well as any other relevant information stored in
the ledger.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Fabric
• Hyperledger’s first incubation project, Fabric, is a permissioned

blockchain platform.
• Hyperledger Fabric was implemented in the Go programming language.
• It is made for enabling consortium blockchains with different degrees of


permissions.
• It is a platform for distributed ledger solutions underpinned by a
modular architecture delivering high degrees of confidentiality,
resiliency, flexibility and scalability.

Key Features
• Channels for sharing confidential information
• Ordering Service delivers transactions consistently to peers in the network
• Endorsement policies for transactions
• CouchDB world state supports wide range of queries

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Fabric Capabilities
Identity management

Privacy and confidentiality

Efficient processing

Chaincode functionality

Modular design

Issues transactions with derived certificates that are unlinkable to


the owning participant, thereby offering anonymity on the network

Ensures that only the intended participants can see the content, by
encrypting the content of each transaction

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Components

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Components “
Let’s have a look at the Hyperledger


Components.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Peer
Peer

A Peer is a node on the network maintaining the state of the ledger and
managing chaincodes.

• Any number of peers may participate in a network.


• A peer can be an endorser, committer and/or submitter (submitter has not Submitter
been implemented).
– An endorser is always a committer.
– An endorser executes and endorses transactions.
– A committer verifies endorsements and validates transaction results.
• A peer manages event hub and delivers events to the
Subscribers.
• Peers form a peer-to-peer gossip network.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Ledger

CouchDB (an external


option) supports keyed
queries, composite keyed
queries, key range
queries and full data-rich
queries (beta in 1.0).

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Channel
Channel is a data partitioning mechanism to control transaction visibility to stakeholders only.

• Consensus takes place within a channel by members of the channel.


• Other members on the network are not allowed to access the channel and will not see
transactions on the channel.

• A chaincode may be deployed on multiple channels; each instance is isolated within its channel.
• A chaincode may query another chaincode in other channels (ACL applied).

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Membership Service Provider (MSP)
Endorser
End User
• An abstraction of identity provider
Endorser
Bob

- <MSP.id, MSP.sign, MSP.verify, MSP.validateid,


Orderer Client
MSP.admin>
- governs application, endorser and orderer identities
Endorser

• Used as building blocks for access control frameworks


- at the system level (read/write access on system
controls and channel creation)
Membership Service
- at the channel level (read/write access) Provider
- at the chaincode level (invocation access)

• Represents a consortium or a member


Fabric Certificate External Certificate
Authority Authority

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Crypto Service Provider (CSP)

• CSP abstracts crypto standards (software and hardware)


to enable plugging in different implementations.
– Alternate implementations of crypto interface can be
used within the Fabric code, without modifying the core.

• Support for Multiple CSPs


– Easy addition of more types of CSPs, e.g., of different
HSM types
– Enable the use of different CSPs on different system
components transparently

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Fabric CA

Member Services
• Default implementation of the Membership Provider

Service Provider Interface Implements


• Issues ECerts (long-term identity) and
TCerts (disposable certificate)
• Supports clustering for HA characteristics
• Supports LDAP for user authentication ECert
• Supports HSM Fabric CA

TCert

Root Certificate
Authority HSM

LDAP
Cluster DB Authenticate
Enroll ID, secretly

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Overview of Application Flow

• Developers create application and smart


contracts (chaincodes).
– Chaincodes are deployed on the network and
control the state of the ledger.
– Application handles the user interface and
submits transactions to the network which is
called a chaincode

• Network emits events on the block of


transactions allowing applications to integrate
with other systems.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Bootstrapping a Network

• It decides on members (MSPs) controlling the ordering service.


– Set up MSP configuration for each member (root certs, signing certs, key, admins, etc.)
– Set up policies governing the network (who has privilege to modify, configure and create channels)
– Start up orders with the configuration

• Each member decides on the number of peers to participate.


– For each peer, issue peer identity (local MSP configuration) and start it up

• At this point, we have a network of peers and orderers.


– Peers are not yet connected to orderers nor to each other

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Two-member Network

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Setting up Channels, Policies &
Chaincodes

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Setting up Channels, Policies & Chaincodes “
Let’s have a look at the business network and


see how many more channels are required?

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Setting up Channels, Policies & Chaincodes “
• Depending on the business network, one or more channels may be required.

• To create a channel, send a configuration transaction to the ordering service


specifying members of the channel, ACL policies and anchor peers.
– The configuration becomes part of the genesis block of the channel.
– Then, notify members to join the channel (a peer may join multiple channels).

• Deploy chaincodes on the channel with an appropriate endorsement policy.


• Now, the network is ready for transacting.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Consensus Redefined

Consensus = Transaction Endorsement + Ordering + Validation

• Endorsement: Each stakeholder decides whether to accept or


reject a transaction

• Ordering: Sorting all transactions within a period into a block to be


committed in that order

• Validation: Verifying whether transaction endorsement satisfied


the policy and transaction transformation is valid according to the
multiversion concurrency control (MVCC)

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Transaction Endorsement

• An endorsement is a signed response of the result of a transaction


execution.
• An endorsement policy encapsulates the requirement for a transaction to
be accepted by stakeholders, either explicit or implicit.
– A signature from both member1 and member2
– Either a signature from both member1 and member2 or a signature
from member3
– A signature from John Doe
• The endorsement policy is specified during a chaincode instantiation on a
channel; each channel chaincode may have different endorsement
policies.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Two-member Network with a Channel

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


N-member Network with Multichannel

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 1 – Proposing Transaction

Application proposes the transaction

Endorsement Policy:
• “E0, E1 and E2 must sign”
• P3 and P4 are not part of the policy

Client application submits a transaction


proposal for Chaincode A. It must target
the required peers {E0, E1, E2}

Key:

Endorser
Ledger
Committer
Ordering Service
Application
Orderer
Fabric Endorsement
Smart Contract
(Chaincode) Policy

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 2 – Executing Proposal

Endorsers execute proposals

E0, E1 and E2 will each execute the


proposed transaction. None of these
executions will update the ledger

Each execution will capture the set of


Read and Write data, called RW sets,
which will now flow in the Fabric

Key:

Endorser Ledger

Ordering Service Committer Application

Orderer Endorsement
Fabric Policy
Smart Contract
(Chaincode)

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 3 – Proposal Response

Application receives responses

RW sets are signed by each endorser and


returned to the application

Key:

Endorser Ledger

Ordering Service Committer Application

Orderer Endorsement
Fabric Policy
Smart Contract
(Chaincode)

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 4 – Ordering Transaction

Application submits responses for


ordering
Application submits responses as a
transaction to be ordered

Ordering happens across the Fabric in


parallel with transactions submitted by
other applications

Key:

Endorser Ledger
Committer

Orderer

Smart Contract (Chaincode)

(Other applications)

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 5 – Delivering Transaction
Orderer delivers to all committing
peers
Ordering service collects transactions into
blocks for distribution to committing peers.
Peers can deliver these to other peers using
gossip (not shown here)
Different ordering algorithms available:
SOLO (single ordering node)
Kafka (blocks are mapped to topics)
SBFT (tolerates faulty peers)

Ordering Service

Fabric

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 6 – Validating Transaction

Committing peers validate transactions


Every committing peer validates against the
endorsement policy. Also, they check if RW
sets are still valid for the current state

Transactions are written to the ledger, and


they update caching DBs with validated
transactions

Ordering Service

Fabric

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Transaction: Step 7 – Notifying Transaction

Committing peers notify applications


Applications can register to be notified
when transactions succeed or fail and
when blocks are added to the ledger

Applications will be notified by each peer


to which they are connected to

Ordering Service

Fabric

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Fabric Roadmap

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Explorer Components

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Explorer Components “
Let’s learn about Hyperledger Explorer


Components.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Explorer Components

Federated identity and


access management

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Composer
• Hyperledger Composer is an extensive, open development toolset and framework used to make
developing blockchain applications easier.
• Hyperledger Composer is a set of collaboration tools for building blockchain business networks
that make it simple and fast for business owners and developers to create smart contracts and
blockchain applications to solve business problems.

• Hyperledger Composer allows us model our business network and integrate existing systems and
data with our blockchain applications.

• Applications use business centric APIs to invoke transactions that create, delete and update assets
and transfer them between participants.

• Assets, participants and transactions are recorded in the worlds state in registries.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Key Development Concepts

• Model files describe the assets, participants, transactions and events that exist in a business
network.
• An expressive modeling language includes relationships, arrays and validation rules.
• Data is serialized as JSON and is fully validated by the Hyperledger Composer runtime.

• Access control lists define rules for sharing and privacy.


• Rules are automatically enforced by the Hyperledger Composer runtime.

• Transaction processor functions implement additional business requirements.


• Standard JavaScript code is executed on the blockchain by the Hyperledger Composer
runtime.

• A business network definition is the set of the above for a given business network.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Business Model Archive

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Model Files

Namespace groups related types

Specific keywords for defining assets, participants,


transactions and events in a business network

Non-abstract types must have an identifying field

Types having a set of properties, denoted with a


leading “o”

Types can have relationships to other types,


denoted with a leading ”-->”

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Access Control Lists
Rules are executed in the order from top to bottom.
If no rule permits access, then access is denied.

Each rule permits or denies permission to a


participant to perform an operation on a resource.
Resources are assets, participants, etc.

Rules can contain complex conditions. Conditions


are written in JavaScript and can access the
participant and resource.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Transaction Processor Functions
Transaction processor functions are written in
standard JavaScript (ES5), and they can use the
runtime API to interact with the blockchain.
Annotations in the comments define the
transaction that the function accepts and that the
function is a transaction processor function.
Transaction processor functions are atomic; either
all updates are applied, or no updates are applied.
They interact with the registry APIs to add, update and
remove assets stored on the blockchain in the world
state.

Use event APIs to publish events to external applications


for notifications and triggering downstream processing.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Business Network Definition
Asset
Cake
Participants
Baker and Customer
Transaction
Cake Sale

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Business Network Execution
Hyperledger Fabric
Blockchain Network

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Sample Business Network with Composer

A Sample Business Network

With Fabric Composer


• Model, test and expose the business network
• Create apps that consume the business network
• Integrate existing systems with the business network

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Composer Playground

• An interactive web tool for the development


(and testing) of business networks without
installing anything

• DSL for specific assets, participants and


transactions in your network
• Live content assist; syntax checking

• Non-web options are also possible


• Hosted and local playgrounds
• Atom and VSCode plug-ins

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Test Business Networks: Composer Playground

• The Test tab on playground reflects a


dynamically defined model

• It creates default registries

• It creates, reads, updates and deletes


resources and submits transactions

• Multiple environments are supported, e.g.,


test, prod, etc.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Composer

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Composer “
Let’s see what Hyperledger Composer is and


what purpose it serves.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Hyperledger Composer “
Hyperledger Composer is an extensive, open development toolset and
framework to make developing blockchain applications easier. Its primary goal
is to accelerate time to value and make it easier to integrate your blockchain


applications with the existing business systems. You can use it to rapidly
develop use cases and deploy a blockchain solution in weeks rather than in
months. It allows you to model your business network and integrate existing
systems and data with your blockchain applications.

Hyperledger Composer supports the existing Hyperledger Fabric blockchain


infrastructure and runtime, which supports pluggable blockchain consensus protocols
to ensure that transactions are validated according to the policy developed by the
designated business network participants.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


How does Hyperledger Composer work?

For an example of a business network in action, a realtor can quickly model their
business network as such:
• Assets: houses and listings


• Participants: buyers and homeowners
• Transactions: buying or selling houses and creating and closing listings

• Participants can have their access to transactions restricted based on their role as
either a buyer, seller or realtor.
• The realtor can then create an application to present buyers and sellers with a
simple user interface for viewing open listings and making offers.
• This business network could also be integrated with the existing inventory system,
adding new houses as assets and removing sold properties.
• Relevant other parties can be registered as participants; for example, a land
registry might interact with a buyer to transfer ownership of the land.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 1: Opening the Composer Playground
Open the Hyperledger Composer Playground. You would see the My Wallet screen.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 2: Creating a New Business Network

Next, we would create a new business network from scratch.
A business network has a couple of defining properties: a name and an optional


description. (You can also choose to base a new business network on an existing
template or import your own template.)

Follow these steps:

1. Click on “Deploy a New Business Network” under the “Web Profile” title to get
started.
2. The new business network needs a name; let's call it “new-network”.
3. Optionally, you can add a network description.
4. Next, we need to select a business network to base ours on, because we want to
build the network from scratch. Click on “empty-business-network”.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Choosing a Business Network Definition

Next, let’s choose a Business Network Definition from the given options.

Choose empty-
business-network

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 3: Connecting to the Business Network

Now that we've created and deployed the


business network, we should see a new ID card
called “admin” for our business network, “new-
network” in your wallet.

• When connecting to an external blockchain,


ID cards represent everything necessary to
connect to a business network. They include
connection details, authentication material
and metadata.

• To connect to our business network, click on


“Connect now” inside our ID card.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Adding Files to Make up a Business Network Definition

Click here to create and


edit files.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 4: Adding a Model File

As you can see, we're in the Define tab now, which is where you
create and edit files that make up a business network definition. As


we have selected an empty business network template, we need to
define our business network files.

The first step is to add a model file. Model files define assets, participants, transactions
and events in our business network.

• Click on the “Add a file” button


• Choose “Model file” and click on “Add”
• Delete the lines of codes in the model file and replace it with this:

This domain model defines a single asset type Commodity and single participant type Trader and a
single transaction type Trade that is used to modify the owner of a commodity.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 5: Adding a Transaction Processor Script File

/**
* Track the trade of a commodity from
Since the domain model has been defined now, one trader to another
we can define the transaction logic for the @param {org.acme.mynetwork.Trade} trade
business network. - the trade to be processed
@transaction */
• These functions are automatically function tradeCommodity(trade) {
executed when a transaction is submitted trade.commodity.owner =
for processing. trade.newOwner; return
getAssetRegistry('org.acme.mynetwork.C
• Click on the “Add a file” button om modity') .then(function
(assetRegistry)
• Choose “Script file” and click on “Add” { return
• Delete the lines of code in the script file and assetRegistry.update(trade.commodity)
replace it with the following code: ;
}); }

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 6: Adding an Access Control File

Access control files define access control rules for /** * Access control rules for
mynetwork */ rule Default {
business networks. (While you can have multiple
description: "Allow all
model or script files, you can only have one access
participants access to all
control file in any business network.) resources" participant: "ANY"
operation: ALL resource:
• Click on the “Add a file” button "org.acme.mynetwork.*" action:
• Choose “Access Control file” and click on “Add” ALLOW } rule SystemACL {
• Delete the lines of code in the access control file description: "System ACL to permit
and replace it with the code given on your right: all access" participant:
"org.hyperledger.composer.system.Pa
rticipant" operation: ALL resource:
"org.hyperledger.composer.system.**
Access control rules allow all participants to access all " action: ALLOW }
business network resources and all users to have system
access control privileges.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 7: Deploying the Updated Business Network

As we've created our model, script and access control files, we need to deploy and test our business
network.

• Click on “Update” to deploy our new model, script and access control files

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 8: Testing the Business Network Definition
Next, we need to test our business network by creating some participants (Traders) and an asset
(Commodity) and then change the ownership of the Commodity by using our Trade transaction.

• Click on the Test tab to get started

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 9: Creating Participants
The first thing we should add to our business network is two participants. (Ensure that you have the Trader tab
selected on the left, and click on Create New Participant in the upper right.)
• What you can see is the data structure of a Trader participant. We want some easily recognizable data, so
delete the code that's there and paste the following:

{ "$class": "org.acme.mynetwork.Trader", "tradeId": "TRADER1", "firstName":


"Jenny", "lastName": "Jones" }

• Click on Create New to create the participant


• You should be able to see the new Trader participant you've created. We need another Trader to test our Trade
transaction. Hence, create another Trader, but this time use the following data:

{ "$class": "org.acme.mynetwork.Trader", "tradeId": "TRADER2", "firstName":


"Amy", "lastName": "Williams" }

Note: Before moving on, make sure that both participants exist in the Trader view!

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Two Participants Created: TRADER1 & TRADER2

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 10: Creating an Asset

Now that we have two Trader participants, we need something for them to trade. Creating an asset is very similar
to creating a participant. The Commodity we're creating will have an owner property indicating that it belongs to
the Trader with the trade ID, TRADER1.

• Choose the “Commodity” tab under “Assets” and click on “Create New Asset”
• Delete the asset data and replace it with the following:

{
"$class": "org.acme.mynetwork.Commodity", "tradingSymbol": "ABC",
"description": "Test commodity", "mainExchange": "Euronext",
"quantity": 72.297,
"owner": "resource:org.acme.mynetwork.Trader#TRADER1 "
}

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Asset Created

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Step 11: Transferring the Commodity
Now that we have two Traders and a Commodity to trade between them, we can test our Trade transaction.
To test our Trade transaction:

• Click on the “Submit Transaction” button on the left


• Ensure that the transaction type is Trade
• Replace the transaction data with the code given below or just change the details:
• Click on “Submit”

{
"$class": "org.acme.mynetwork.Trade", "commodity":
"resource:org.acme.mynetwork.Commodity#ABC", "newOwner":
"resource:org.acme.mynetwork.Trader#TRADER2"
}

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Submit Transaction Successful

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Change in Ownership
• To check whether our asset has changed its ownership from TRADER1 to TRADER2, click on the “Commodity”
tab and expand the data section for the asset. You would see that the owner is listed as:

resource:org.acme.mynetwork.Trader#TRADER2

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Check All Transactions
• To view the full transaction history of our business network, click on All Transactions on the left

You can see that certain actions that we performed using the UI, like creating the Trader participants and the
Commodity asset, are recorded as transactions, even though they're not defined as transactions in our business
network model. These transactions are known as 'System Transactions’. They are common to all business
networks and are defined in the Hyperledger Composer Runtime.

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Quiz

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Quiz 1

Q. Which one of them is a Hyperledger tool?

A. Hyperledger Cello

B. Hyperledger Composer

C. Hyperledger Explorer

D. All of the above

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Answer 1

Q. Which one of them is a Hyperledger tool?

A. Hyperledger Cello

B. Hyperledger Composer

C. Hyperledger Explorer

D. All of the above

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Quiz 2

Q. Which one of them is a Hyperledger Component?

A. Peer

B. Ledger

C. Channel

D. All of the above

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Answer 2

Q. Which one of them is a Hyperledger Component?

A. Peer

B. Ledger

C. Channel

D. All of the above

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.


Thank You
Email us: [email protected]

Visit us: https://intellipaat.com

© Copyright, Intellipaat Software Solutions Pvt. Ltd. All rights reserved.

You might also like