Understanding Hyperledger Frameworks
Understanding Hyperledger Frameworks
What is Hyperledger?
Hyperledger is an open-source project initiated by the Linux Foundation with the goal of
advancing blockchain technologies for enterprise use. It is a collaborative effort to develop and
promote blockchain frameworks and tools that can help businesses create highly secure, scalable,
and efficient distributed ledger systems. Unlike public blockchains like Bitcoin or Ethereum,
which are designed primarily for decentralized digital currency and trustless systems,
Hyperledger focuses on permissioned blockchains designed for private, permission-based
networks, where participants are known and trusted.
Hyperledger is not just a single technology but rather a collection of different blockchain
frameworks and tools that serve various needs. Here are the key projects and components that
make up the Hyperledger ecosystem:
Hyperledger Fabric
Fabric is the most well-known framework within Hyperledger and is designed for enterprise
blockchain solutions. It is a permissioned blockchain that focuses on security, scalability, and
modularity. Let’s break down the key features of Hyperledger Fabric:
1. Modular Architecture: Fabric's most powerful feature is its modularity. It allows for
customization at almost every level of the blockchain network. For example, users can
choose the consensus algorithm (e.g., Raft or PBFT), decide how chaincode (smart
contracts) is executed, and control the network configuration, including how data is
stored.
2. Channels: Fabric introduces the concept of channels, which are private, isolated
networks within the overall network. These channels allow participants in different
transactions to share data without exposing it to everyone else on the network. This is a
major advantage in industries where privacy and confidentiality are crucial (e.g., banking,
healthcare).
3. Smart Contracts (Chaincode): In Hyperledger Fabric, the term chaincode is used for
what is commonly referred to as smart contracts in other blockchain platforms.
Chaincode is used to define the business logic for transactions. Fabric supports writing
chaincode in Go, Java, and JavaScript, making it flexible for developers from various
backgrounds.
4. Consensus Mechanisms: Hyperledger Fabric allows different consensus algorithms to
be used based on the needs of the business. Popular consensus mechanisms include Raft
(leader-based) and PBFT (Practical Byzantine Fault Tolerance), which ensures that the
network can maintain agreement even in the case of faulty or malicious nodes.
5. Endorsement Policies: A key feature of Fabric is its endorsement model, which specifies
which peers must validate and approve a transaction. For example, a policy might say
that at least two out of five designated endorsing peers must sign off on a transaction
before it can proceed. This ensures that transactions are approved by trusted participants.
Hyperledger Sawtooth
Iroha is a simpler and lightweight framework designed for mobile and web applications. It is
easy to deploy and use and is intended for projects that don’t need the complexity of Fabric or
Sawtooth. Some features include:
1. Simple Design: Iroha is designed with simplicity in mind, making it suitable for use
cases like identity management and asset management.
2. Mobile-Friendly: Iroha is particularly well-suited for use in mobile and IoT applications
because it allows for the creation of lightweight blockchain-based solutions.
Hyperledger Indy
Hyperledger Burrow
Hyperledger Caliper
Caliper is a blockchain benchmarking tool that helps measure the performance of different
blockchain implementations. It helps businesses to:
1. Test Scalability: Caliper allows you to test how many transactions a blockchain can
handle per second, the latency of transactions, and how well the system scales as more
participants are added.
2. Benchmark Different Networks: It’s useful for comparing performance between
different blockchain frameworks (e.g., Fabric vs Sawtooth) to determine which is best
suited for your needs.
Let’s go through how Hyperledger Fabric (the most commonly used framework) works in
detail.
1. Transaction Proposal:
o A user or an application sends a transaction proposal to the network. This
proposal typically requests an action, like transferring assets or executing a smart
contract. The transaction proposal is forwarded to a set of endorsing peers, which
validate whether the transaction makes sense in the current context.
2. Endorsement:
o The endorsing peers simulate the transaction using their own version of the ledger
to check whether it’s valid. If they agree, they send back an endorsement to the
client application, essentially saying, "This transaction looks good."
3. Transaction Submission:
o After gathering enough endorsements from the required endorsing peers, the
client submits the transaction to the ordering service, which is responsible for
arranging transactions in the correct order.
4. Ordering and Consensus:
o The ordering service doesn’t care about the content of the transactions; it only
ensures that they are ordered consistently. Once transactions are ordered, they are
grouped into blocks, which are then broadcast to all peers on the network.
5. Validation and Commitment:
o Once the peers receive the blocks, they validate the transactions by checking
whether the endorsements and signatures are correct and whether the transaction
doesn't violate any business rules. If the transaction is valid, it is committed to the
ledger, and the ledger is updated across all peers.
6. End Result:
o All peers in the network now have an updated and consistent view of the ledger.
This ensures transparency, integrity, and security of data across the network.
What is Consensus?
At the core, consensus in the context of blockchain is simply a way to make sure that everyone
in the network agrees on what the “truth” is. In a blockchain, the "truth" is the shared ledger that
records all transactions. In other words, it's how everyone in the system agrees on the state of the
data.
In Hyperledger, a permissioned blockchain, this is very important because you don’t have
anonymous users like in public blockchains (e.g., Bitcoin). Instead, the users are known entities
(e.g., businesses, organizations, or participants) that trust each other to some extent but still need
to validate and agree on the transactions.
Let’s use Hyperledger Fabric, one of the most common frameworks in the Hyperledger project,
as an example. The process of reaching consensus in Hyperledger Fabric follows several clear
steps:
For example:
The proposal might say, “I want to transfer 100 units of currency from account A to
account B.”
The endorsing peers will check if this transaction follows the rules, like checking if
Account A has enough units to transfer.
The endorsing peers don’t immediately apply the transaction to the ledger. Instead, they simulate
the transaction (like testing it without making any real changes) and then give an endorsement.
This endorsement says, “We checked the transaction, and it looks good to go.” Each endorsing
peer signs this response to confirm it.
Think of it like having three referees in a sports game. Each referee watches the same play, and if
they all agree that it was fair, they sign a report saying the play was valid.
Endorsement Policy: This is a rule that says how many and which peers need to endorse a
transaction. For example, the policy might say that at least two out of three specific peers must
sign off on the transaction for it to proceed.
Once the client (the one who made the proposal) collects enough endorsements from the referees
(endorsing peers), the transaction is sent to the ordering service.
The ordering service is like the central coordinator that makes sure all transactions are placed
in the right order. It doesn’t care about whether the transaction is valid — it only makes sure that
all transactions happen in a sequence that everyone agrees on.
It’s like a referee crew that orders the sequence of plays in a game, ensuring they happen in a fair
and consistent way.
Now, the ordering service needs a way to decide which transactions go in which order. This is
where the consensus algorithm comes in. The ordering service uses an algorithm to ensure that
all nodes (computers) in the network agree on the order of transactions.
There are two main consensus algorithms in Hyperledger Fabric:
Raft: This is a simple, leader-based approach. One node (the leader) is responsible for
ordering transactions, and the others follow the leader's instructions. It’s like having one
referee make all the decisions, while the others just follow the leader.
PBFT (Practical Byzantine Fault Tolerance): This one is more complex and allows
multiple nodes to make decisions together. It’s like having several referees
communicating with each other to agree on the fairness of each play. It can deal with
some referees acting in a faulty or malicious way.
Once the transactions are ordered, the peers (the nodes that store the ledger) receive the ordered
transactions in blocks. Now, each peer needs to validate the transactions in the block.
Endorsement: Was the transaction approved by the right number of endorsing peers?
Conflict check: Is the transaction trying to do something that conflicts with other
transactions? For example, is it trying to spend money that isn’t there?
Once the transactions pass the validation checks, the peers apply them to their ledger (which is
like the record book where all transactions are stored). Now, the ledger is updated with the new
state of things.
In a permissioned blockchain like Hyperledger, the network is more controlled, meaning the
participants (peers) are known and trusted to some extent. However, they still need a process to
verify transactions to avoid mistakes, fraud, or malicious actions.
1. Endorsement policy ensures that only a specific set of trusted peers approve a
transaction.
2. Consensus mechanisms (like Raft or PBFT) ensure that all participants agree on the
order of transactions.
3. Transaction validation checks for errors or conflicts before any changes are made to the
ledger.
This process ensures that even if a small number of peers are faulty or behave maliciously, the
network can still reach agreement on the valid transactions.
Why Is This Important?
Ensure fairness: All participants agree on the same transactions, preventing fraud or
mistakes.
Guarantee reliability: Even if some peers fail or act maliciously, the system can still
work and make decisions.
Scale effectively: Since endorsement, ordering, and validation happen in different steps,
the system can handle many transactions more efficiently.
Let’s break down the consensus process step by step, focusing on the most commonly used
framework in Hyperledger—Hyperledger Fabric—which includes a modular consensus system
and a flexible approach to consensus.
In Hyperledger Fabric, the process begins with the client application initiating a transaction
proposal that requests an operation to be performed on the blockchain. For example, a business
might propose to transfer an asset or record a change in the state of a product in a supply chain.
Key Steps in this Phase:
The endorsement process ensures that transactions are only considered valid if they meet
the business rules encoded in the chaincode and are agreed upon by trusted parties.
2. Transaction Ordering
After the transaction proposal is endorsed by the required number of endorsing peers, the next
step is to order the transactions. This is where ordering service comes into play. The ordering
service is responsible for establishing the order in which transactions are added to the
blockchain.
In this step, the ordering service does not look at the transaction’s content; it just
ensures that they are ordered consistently across the entire network.
Transaction Block Creation: Once the transactions are ordered, they are grouped into a
block and prepared for final validation.
Once the ordered block containing the transactions is created, it is sent to all peers for
validation and commitment. Each peer validates the block before adding it to their version of
the ledger.
Validation: Each peer checks the transactions in the block to ensure that:
1. The endorsements are valid (i.e., the transactions have been endorsed by the
required number of peers).
2. The transaction hasn’t already been included in the ledger.
3. The state of the ledger is still consistent with the transaction’s proposed changes
(i.e., no double-spending or conflicting operations).
Commitment: After validation, each peer commits the block to their local copy of the
ledger. At this point, the ledger is updated, and the transaction is officially recorded in
the blockchain.
Event Notification: Once the transaction is committed, an event is triggered to notify
interested parties, such as applications or other systems, that the transaction has been
successfully committed to the ledger.
1. Peers
Peers are like the workers or participants in the network. They keep track of the blockchain and
play different roles:
Endorsing Peers: These are the peers that check if the transactions are correct. They
don’t immediately record them, but they verify that the transaction follows the rules and
then sign off on it (this is called endorsing).
Committer Peers: These peers record the transactions into the blockchain once they
have been validated and endorsed.
Anchor Peers: These peers help with communication between different organizations in
the network. They make sure peers from different organizations can talk to each other.
2. Ordering Service
Think of the ordering service as a traffic controller. Its job is to take all the validated
transactions from the endorsing peers and order them in the right sequence before adding them
to the blockchain.
It doesn’t check the transactions for correctness, it just arranges them in the correct
order.
The ordering service uses a consensus mechanism (a way to agree on the transaction
order), such as Raft (which is like a voting system for the network participants).
3. Ledger
The ledger is where all the data about transactions is stored. It has two important parts:
Blockchain: This is like the history book. It stores every transaction that happens in the
network. Once a transaction is confirmed, it is added to the blockchain and can’t be
changed or erased.
State Database: This is like the current state of the network. It keeps track of the latest
values of things, such as how many assets are owned by a person. This helps the system
to quickly check the current status without needing to read through the whole history.
Chaincode is simply smart contracts—the rules that govern how transactions can happen on
the blockchain. It’s like the programming code that defines the business logic.
For example, if a person wants to transfer an asset, the chaincode will define whether that action
is valid (e.g., does the sender have enough of the asset to transfer?). It ensures all the rules are
followed when transactions happen.
5. Channels
Channels allow for privacy. Even though the same network is shared by many
participants, each group can keep its transactions private from others.
For example, if Organization A and Organization B want to work together on a project, they
can set up a channel where only they can see the transactions, even though other organizations
are on the same network.
The Certificate Authority (CA) is like a trusted identity provider. It verifies who each
participant is and gives them an identity certificate. These certificates are used to authenticate
people, organizations, and peers in the network.
When a new participant wants to join the network (e.g., a new organization), the CA
checks their identity and gives them the proper credentials.
If someone’s credentials are revoked (e.g., if they leave the network), the CA can remove
their access.
Network Policies: These define the rules for how the network works. For example,
which peers can join, how transactions are validated, and who gets to see which data.
Endorsement Policies: These define who needs to approve a transaction before it’s
considered valid. For instance, the policy might say, "For a transaction to be valid, two
out of three peers need to endorse it." These policies make sure that the right people
approve a transaction before it goes through.
8. Clients
Clients are like users or applications that interact with the network. They ask the network to
perform actions like submitting transactions, checking the status of the ledger, or interacting with
smart contracts.
Clients don’t hold the blockchain themselves; they send requests to peers.
They use special Software Development Kits (SDKs) to make it easier for developers to
create applications that interact with Hyperledger Fabric.
The SDKs (Software Development Kits) are tools that developers use to build applications that
communicate with the blockchain. They act as a bridge between the client application and the
blockchain network.
SDKs help developers send transaction requests, query the ledger, and call the chaincode
(smart contracts).
Configuration files are the settings for the blockchain network. These files tell Hyperledger
Fabric how the network should operate. For example, they define:
Chaincode in Hyperledger Fabric is essentially the smart contract that governs the logic for
how transactions are executed on the blockchain. It is where you define the rules and operations
of the business application running on Hyperledger Fabric. Let’s break down its design and
implementation without going into specific coding details.
1. What is Chaincode?
Chaincode is the term used for smart contracts in Hyperledger Fabric. It defines the business
logic or the rules for how transactions should be validated and how data should be managed on
the blockchain. Chaincode ensures that the data on the blockchain is accurate, up-to-date, and
adheres to the established rules.
In simpler terms, it's the "code" that runs on the blockchain network and defines what operations
are allowed and how the data should be manipulated when those operations happen.
Initialization: When chaincode is first deployed to the blockchain network, it may need
to perform some setup, such as creating initial records or setting default values. This is
usually done through the init function.
Transaction Execution: When a client sends a transaction request to the blockchain,
chaincode checks whether the transaction is valid according to its logic. The invoke
function is responsible for executing transactions such as adding new records, updating
existing ones, or transferring assets.
State Management: Chaincode interacts with the ledger (a database-like structure)
where data is stored. It can read data from the ledger (e.g., to check an asset’s current
value) and write new data (e.g., when adding new records).
a. Installation
Chaincode must be installed on all peer nodes (computers that participate in the
network). These peers are the ones that execute the chaincode.
b. Instantiation
Once installed, the chaincode needs to be instantiated (deployed) on the network. During
this stage, the init function is called, which is where any initial setup or data population
takes place. This is the moment when the chaincode starts running on the blockchain.
c. Invocation
After instantiation, clients (users or applications) can invoke the chaincode to propose
transactions. For instance, a client might request to add a new car record or transfer
ownership of an asset. The invoke function processes these requests, validates them, and
then updates the blockchain if the request is valid.
d. Upgrade
As business needs change, the chaincode might need to be updated. This can be done by
deploying a new version of the chaincode. When chaincode is upgraded, the system
checks and applies the necessary changes while ensuring the previous transactions remain
intact.
4. Designing Chaincode
The first step is to understand the problem you're solving. The business logic could involve
operations like:
Based on these operations, you can start defining what the chaincode will do.
You need to decide what kind of data will be stored on the blockchain. For example, if you're
building a supply chain application, the data might include products, shipping statuses, and
transaction history.
This data must be represented in a format (like a Car object or Product object) that can be
easily accessed, modified, and queried.
Define what operations the chaincode should perform. Typical operations include:
1. Client Request: A client application sends a transaction request to the network. For
example, this could be a request to transfer ownership of an asset, such as a car, from one
person to another.
2. Chaincode Validation: The chaincode validates the transaction based on its business
rules. For instance, it checks if the current owner of the asset has permission to transfer
ownership, whether the asset exists, and if the transfer conditions are met.
3. Endorsement: The request is sent to endorse peers for validation. These peers check the
chaincode’s logic to ensure the transaction is valid. If the peers agree, they "endorse" the
transaction and send it back to the client.
4. Ordering: The ordering service groups endorsed transactions into blocks and orders
them. These blocks are then added to the blockchain in a sequential order.
5. Commitment: After ordering, the committing peers update the blockchain with the new
block of transactions. The state of the blockchain (data ledger) is now updated to reflect
the new transaction, such as the updated ownership of the car.
Security: Chaincode ensures that only valid transactions can be executed based on the
business logic. Transactions are checked before being written to the ledger.
Immutability: Once a transaction is committed to the blockchain, it cannot be changed
or erased. This ensures the integrity and trustworthiness of data.
Flexibility: Since Hyperledger Fabric supports multiple programming languages (Go,
Java, JavaScript), developers can write chaincode in the language they are most
comfortable with.
Privacy: Using channels in Hyperledger Fabric, chaincode can ensure that transactions
are private and only visible to authorized parties.
Unit Testing: Testing individual chaincode functions to make sure each operation works
as expected.
End-to-End Testing: Simulating real-world use cases to test how the entire system
works, from client interaction to blockchain updates.
Performance Testing: Checking the scalability of chaincode to handle a large number of
transactions or requests.
Once tested, the chaincode is installed, instantiated, and invoked as needed by the clients.
When business logic changes, the chaincode can be upgraded without affecting previous data or
transactions.
The Hyperledger Fabric SDK is a crucial tool that connects your application (whether backend
or front-end) to the Fabric blockchain network. Think of it as the communication bridge between
the blockchain's underlying ledger and the business logic you've defined in chaincode.
The SDK handles many operations, such as managing network connections, submitting
transactions, querying data, and handling user identities. It abstracts the complex interactions
with the blockchain so that developers can focus on creating the business logic and user
interface.
Hyperledger Fabric offers SDKs for several popular programming languages, allowing
developers to build applications in their preferred environment.
1. [Link] SDK:
o This is the most commonly used SDK for web and server-side JavaScript
applications.
o It provides a rich API to interact with the blockchain network, submit
transactions, query the ledger, and handle identity management.
2. Java SDK:
o The Java SDK is for developers working in Java environments, commonly used in
enterprise applications.
o It provides similar functionality to the [Link] SDK, but tailored for Java-based
applications.
3. Go SDK:
o The Go SDK is designed for Go (Golang) developers and provides functions to
interact with the Hyperledger Fabric network, just like the [Link] and Java
SDKs.
4. Python SDK (Community-Supported):
o There isn't an official Python SDK from Hyperledger Fabric, but community-
driven efforts provide the ability to use Fabric with Python applications.
Each SDK is designed to simplify interaction with the Fabric network and abstracts complex
blockchain operations like peer communication, transaction endorsement, and event
listening.
How SDK Works in Detail
1. Establishing Connection:
o Configuration Files: The SDK loads connection profiles that describe the Fabric
network, including the details of peers, channels, and ordering services. This
configuration helps the SDK understand how to connect to different nodes in the
network.
o Gateway: The Gateway in the SDK is responsible for connecting to the Fabric
network. It authenticates the client and manages the interaction between the client
application and the network. The Gateway abstracts away much of the low-level
complexity of interacting with the Fabric network.
2. Endorsement and Validation:
o When a transaction request is sent, endorsement is the process where peer nodes
validate the transaction proposal. This ensures that the transaction meets the
business rules as defined in the chaincode.
o The SDK manages this endorsement process, collects the endorsed responses
from peer nodes, and then submits the endorsed transaction to the ordering
service.
3. Transaction Submission:
o Once endorsed, the transaction is ordered and placed into blocks, which are then
committed to the blockchain ledger.
o The SDK can query the status of the transaction (e.g., success or failure) and
provide real-time feedback to the user.
4. Listening for Blockchain Events:
o The SDK allows applications to listen for events such as the completion of a
transaction, block commits, or changes to the ledger state. This is useful for
applications that require real-time updates or notifications based on blockchain
activities.
2. Front-End Development
Once the backend interactions are taken care of by the Fabric SDK, the next piece is providing a
user-friendly interface through which users can interact with the blockchain. This is typically
achieved via front-end web applications, mobile apps, or desktop software. The front-end is
what the end-users see and interact with, and it communicates with the blockchain through the
Fabric SDK.
Imagine you are building a car ownership system using Hyperledger Fabric.
1. Home Page:
o The front-end displays a list of cars owned by the logged-in user, showing
information like the make, model, and VIN (vehicle identification number).
o This data is pulled from the blockchain via queries made through the Fabric
SDK.
2. Transfer Ownership:
o The user clicks on a car and selects the option to transfer ownership to another
user.
o They fill out a form with the new owner’s details, and the front-end sends a
request to the back-end (via SDK) to invoke the chaincode and transfer
ownership.
o The SDK submits the transaction to the Fabric network. Once the transaction is
validated and committed to the blockchain, the front-end updates to show the new
owner.
3. Real-Time Updates:
o The front-end listens for events (e.g., "transaction committed" or "block
updated"). Once the transaction is completed and the new ownership is recorded,
the UI updates in real-time to reflect the change.
4. User Authentication:
o Before the user can perform any transaction, they must authenticate. The front-
end integrates with the Fabric CA to handle certificate-based login.
Imagine you're building a business app — like for managing car ownership, land records, or
supply chains — but instead of using a regular database, you want to use blockchain.
Hyperledger Composer was a set of tools that made it easy for people (even beginners) to
design, build, and test these kinds of blockchain apps on Hyperledger Fabric.
It was like a toolkit and playground rolled into one, to help you model real-world things (like
people, products, and contracts) and create logic (rules, permissions) without diving deep into
complex blockchain code.
You can package all of this into a neat file that can be deployed onto the blockchain.
2. Modeling Tools (for describing data)
This lets you define what kind of data you're working with, like:
What a product looks like (e.g., it has a name, serial number, and price),
Who owns it (e.g., a person or a company),
What kind of transactions can happen (like buying, selling, or transferring).
Once you have your data, you need to decide how things work.
For example:
This tool allows you to define the rules and actions your app should take when users interact
with it.
Playground was great for learning and trying out ideas without writing much code.
It’s like a "demo room" where you build and test your app before going live.
Once your app is ready, you’ll probably want others to use it — like through a website or mobile
app.
Instantly creates a way for outside applications to talk to your blockchain app.
Lets developers build interfaces (front-end apps) more easily.
Acts like a “translator” between regular apps and your blockchain backend.
So, you didn’t need to write complicated code to connect your app to the blockchain —
Composer did it for you.
For those who preferred working in the terminal, the CLI allowed you to:
List of car owners and cars Modeling tools (Participants & Assets)
Rules like “Only the owner can sell a car” Logic builder & Access control rules
Hyperledger Composer helped people design, build, and test blockchain apps quickly.
It included tools for defining who is involved, what data is tracked, and how
everything works.
It gave you a visual way to try out ideas and test transactions.
It created automatic APIs so other apps could talk to the blockchain easily.
Although it's not used anymore in production, it's a great stepping stone to learning
Hyperledger Fabric.