Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Introduction:

➢ It is the most popular enterprise-grade blockchain platforms on the market now.


➢ Hyperledger is an umbrella project where other multiple projects are developing under it.
➢ At present Hyperledger happens to have 14 projects under their wings. Among them,
Hyperledger Fabric is the most popular one so far.

Hyperledger:

➢ Hyperledger is not a blockchain, but a project that was initiated by the Linux Foundation in
December 2015 to advance blockchain technology.
➢ This project is a collaborative effort by its members to build an open source distributed ledger
framework that can be used to develop and implement cross-industry blockchain applications
and systems.
➢ The principal focus is to create and run platforms that support global business transactions.
➢ The project also focuses on improving the reliability and performance of blockchain systems.

Projects under Hyperledger:

➢ There are four categories of projects under Hyperledger. Under each category, there are
multiple projects. The categories are:
➢ Distributed ledgers
➢ Libraries
➢ Tools
➢ Domain-specific
➢ Distributed ledger projects: Fabric, Sawtooth, Iroha, Indy, Besu, and Burrow.
➢ Under libraries: Aries, Transact, Quilt, and Ursa projects.
➢ The tools category: Avalon, Cello, Caliper, and Explorer.
➢ Domain-specific projects: Hyperledger Grid and Hyperledger Labs.

What Is Hyperledger Fabric?

➢ This is one of the most popular project in hyperledger.


➢ Hyperledger fabric was made in corporation with IBM and Digital Assest.
➢ It is permissioned blockchain infrastructure used to build blockchain-based products, software
and applications.
➢ It defines modular architecture that defines roles between nodes, execution of smart
contracts, as well as pluggable hyperledger fabric consensus protocols.
➢ Hyperledger fabric supports different programming languages through the installation of
modules.
➢ Hypeledger fabric is used to with integration projects that need a distributed ledger.
How Hyperledger Fabric Works

➢ Traditional blockchain networks can’t support private transactions and confidential contracts
that are of utmost importance for businesses.
➢ Hyperledger Fabric was designed in response to this as a modular, scalable and secure
foundation for offering industrial blockchain solutions.
➢ Within private industrial networks, the verifiable identity of a participant is a primary
requirement.
➢ Hyperledger Fabric supports memberships based on permission; all network participants must
have known identities.
➢ Many business sectors, such as healthcare and finance, are bound by data protection
regulations that mandate maintaining data about the various participants and their respective
access to various data points.
➢ Fabric supports such permission-based membership.

Example of Hyperledger Fabric

➢ Suppose there's a manufacturer that wants to ship chocolates to a specific retailer or market of
retailers (i.e., all US retailers) at a specific price but does not want to reveal that price in other
markets (i.e., Chinese retailers).
➢ Hyperledger Fabric addresses this issue by keeping private transactions private on the network;
only participants who need to know are aware of the necessary details.
➢ Data partitioning on the blockchain allows specific data points to be accessible only to the
parties who need to know.

Basic Benefits of Hyperledger Fabric

Open-Source
➢ Hyperledger Fabric blockchain is an open-source platform, so everyone is free to use it. Thus, it
means that you won’t have to buy it from them if you want to use it for any of your projects.
More so, there is no vendor lock-ins as well.
➢ However, in many cases, the industries want to add more features or don’t want to waste
money on developer fees. It’s because even though the source code is free, you would need to
have developing skills to understand what you are dealing with.And so, you would need a team
of programmers that can understand it. Moreover, you can also add or remove some of the
features to make the Hyperledger fabric blockchain more suitable for your industry.

Suitable For Wide-Ranging Industry

➢ The platform can go with any kind of industry at present. So, it means no matter what kind of
company you have, it would go perfectly with it.
➢ In reality, industries such as supply chain, banking, Internet of Things, healthcare, government,
media, cybersecurity, and many others are pursuing it.
Quality Code

➢ It offers careful observations to make sure that the quality prevails with every new addition.
This is one of the best parts of the Hyperledger Fabric blockchain.
➢ According to the Hyperledger fabric docs, you’ll see that all their codes go through a crucial
inspection.
➢ In reality, they want to focus more on quality than quantity. So, if they add any new features, it
goes through heavy testing phases to find out any hidden fault.
➢ Moreover, as the Hyperledger fabric are open-sourced, the community also contributed greatly
to perfecting the codebase. Thus, you will always get a premium level of quality when it comes
to Hyperledger fabric.

Higher Efficiency

➢ It provides more efficiency compared to other blockchain platforms.


➢ In reality, the internal structure of the Hyperledger fabric blockchain promotes efficiency.
➢ Every node within the Hyperledger fabric has a different work assignment. So, it can separate
the transactions form other commitment and ordering processes.
➢ Thus, the nodes can process multiple transactions simultaneously without making the system
slow. Moreover, this new structure makes sure that the time consumption is relatively low and
accelerates the overall functionality.
➢ Parallel to that, many nodes do not have the burden of processing the transactions. However,
these nodes can focus on ledger maintenance or authentication.

Modular Design

➢ The modular design ensures greater functionality of the network.


➢ In reality, you get to use different algorithms to run on the Hyperledger fabric for different
purposes.
➢ For example, you can choose an algorithm for encryption, another for identity and another for
consensus. For this, all you have to do is to plug it in the Hyperledger Fabric blockchain. So, you
are not stuck with only one type of algorithm to run on the Hyperledger Fabric blockchain.
Hyperledger Fabric Architectural Model

Assets
➢ Assets can be anything that holds a monetary value on the system.

➢ All the assets are represented as the key-value pair.

➢ You can represent the assets in binary form.

Chaincode
➢ chaincode is actually a business logic that can define an asset and other transactional
modification of that asset.

➢ In reality, chaincode runs separately from transaction orders, which optimizes the network for
more security.

➢ You can execute a chaincode using a transitional proposal. Later the execution will then change
the state of the asset.

Ledger
➢ It encodes all the transaction history in an immutable ledger.

➢ The ledger is sequenced, and you can’t change the state of a transaction once it gets on the
ledger.This makes the ledger quite robust.

➢ It comes with access control lists so that only the person that has access to it can see it. In
reality, if a person doesn’t have the right to see the information, then he/she can’t penetrate
the security protocols.
Identity
➢ Hyperledger Fabric smart contract offers a membership identity service that helps to manage all
the identities in the permissioned network.

➢ With the help of this element, you can choose who can enter the network and who can’t. And
so, you will ultimately limit your internal network from outer reach.

➢ It’s actually a great solution for Enterprise Company’s because there is much information that
shouldn’t fall into the public hands.

Confidentiality and Privacy


➢ With permissioned entering, you are getting confidentiality and privacy in the Hyperledger
fabric architecture diagram.

➢ Moreover, it comes with data restrictions and private transaction facilities. Anyhow you can
share the ledger with the whole network of nodes, but you can also set privileges for other
parties as well.

Security Protocols
➢ You will get a higher degree of security protocols to safeguard the network from any attacks.

➢ In the Hyperledger fabric architecture diagram, you will get an encryption mechanism to
safeguard all the information on the ledger. So, anyone would see encrypted information
instead of the real thing.

➢ That makes this platform an excellent choice when it comes to enterprise companies. In reality,
high-end companies always face an imminent threat of cyber-attacks. But with the help of
blockchain technology, they can easily be safe.

Consensus
➢ It offers a unique approach for reaching consensus makes it perfect for the enterprise-grade
solution.

➢ In reality, Hyperledger Fabric consensus algorithms operate on Kafka model.

➢ But it’s just for reference purposes. In reality, you can use other consensus mechanisms for
ordering purposes as well.

➢ To maintain the integrity of the system, Hyperledger fabric consensus algorithm is a must.
Properties of the consensus are:

➢ Liveliness: Here, all the non-faulty nodes will get the submitted transaction.
➢ Safety: All the nodes in the system will get the same sequence of output for the same
sequence of input. So, it means that when the nodes get identical transaction series, all the
state changes will be the same as well.

Hyperledger Fabric Consensus Algorithm at Present:

Solo
➢ Solo is mostly a developer’s favorite algorithm for experimenting.

➢ It only includes a single node and definitely not suitable for production scenarios.

Kafka
➢ Kafka is a crash fault-tolerance (the algorithm can correctly take the process forward and reach
consensus, even if certain components fail) consensus algorithm.

➢ This algorithm solves the problem of nodes crashing.

➢ In decentralized system where nodes can halt or disconnect from the network. We maintain the
same state of truth on the system.
Consensus in Hyperledger Fabric
The consensus mechanism in Hyperledger Fabric consists of three steps:
1. Transaction endorsement: This process endorses the transactions by simulating the transaction
execution process.
2. Ordering: This is a service provided by the cluster of orderers which takes endorsed
transactions and decide on a sequence in which the transactions will be written to the
ledger.
3. Validation and commitment: This process is executed by committing peers which first
validates the transactions received from the orderers and then commit that transaction to the
ledger.
These steps are shown in the following flowchart:
HyperLedger Fabric Transaction Lifecycle:

A more detailed explanation of the above three steps is mentioned in below transactional flow.

Transaction Flow for a Visual Representation of Consensus

• The client application requests a transaction.


• SDK application generates a transaction proposal and sends it to endorsing peers.
• Endorsing peers verify:
o The transaction proposed is well in the form.
o Not submitted before.
o The signature is valid.
o The client is authorized to perform the concerned operation.
• The transaction proposal inputs as arguments are passed to chain code or smart
contract and further to SDK application.
• The application verifies the signature and compares the proposal responses to be the
same.
• Application broadcasts the transaction containing read/write sets and signature to
order service.
• Ordering peers prepare the block and transmit it to all the peers.
• Each peer appends the block to the chain, and for each valid transaction, the write sets
are committed to the database.
Smart Contracts , Solidity language
Smart Contacts
Def : A Smart Contract (or cryptocontract) is a computer program that directly and
automatically controls the transfer of digital assets between the parties under certain
conditions.
➢ A smart contract works in the same way as a traditional contract while also
automatically enforcing the contract.
➢ Smart contracts are programs that execute exactly as they are set up(coded,
programmed) by their creators. Just like a traditional contract is enforceable by
law, smart contracts are enforceable by code.

➢ Smart contracts are self – executing contracts which contain the terms and
conditions of an agreement between the peers.
➔ Smart contacts will work like:
• The terms and conditions of an agreement is written in the code
• It executes in blockchain decentralized platform
• These agreements facilitate the exchange of money, shares, property etc.
➢ The bitcoin network was the first to use some sort of smart contract by using them to
transfer value from one person to another.
➢ The smartcontract employs basic conditions like checking if the amount of value to
transfer is actually available in the sender account.
➢ Later, the Ethereum platform emerged which was considered more powerful,
precisely because the developers/programmers could make custom contracts in a
Turing-complete language.
➢ It is to be noted that the contracts written in the case of the bitcoin network were
written in a Turing-incomplete language, restricting the potential of smart contracts
implementation in the bitcoin network.
How Do Smart Contracts Work?
A smart contract is just a digital contract with the security coding of the blockchain.
➢ It has details and permissions written in code that require an exact sequence of
events to take place to trigger the agreement of the terms mentioned in the smart
contract.
➢ It can also include the time constraints that can introduce deadlines in the
contract.
➢ Every smart contract has its address in the blockchain. The contract can be
interacted with by using its address presuming the contract has been broadcasted
on the network.
The idea behind smart contracts is pretty simple. They are executed on a basis of simple logic,
IF-THEN for example:
➢ IF you send object A, THEN the sum (of money, in cryptocurrency) will be
transferred to you.
➢ IF you transfer a certain amount of digital assets (cryptocurrency, for example,
ether, bitcoin), THEN the A object will be transferred to you.
➢ IF I finish the work, THEN the digital assets mentioned in the contract will be
transferred to me.
Applications of Smart Contracts
1. Real Estate: Reduce money paid to the middleman and distribute between the parties
actually involved. For example, a smart contract to transfer ownership of an apartment
once a certain amount of resources have been transferred to the seller’s account(or
wallet).
2. Government elections: Once the votes are logged in the blockchain, it would be very
hard to decrypt the voter address and modify the vote leading to more confidence against
the ill practices.
3. Management: The blockchain application in management can streamline and automate
many decisions that are taken late or deferred.
4. Healthcare: Automating healthcare payment processes using smart contracts can prevent
fraud.
Advantages of Smart Contracts
1. Recordkeeping: All contract transactions are stored in chronological order in the
blockchain and can be accessed along with the complete audit trail. However, the parties
involved can be secured cryptographically for full privacy.
2. Autonomy: There are direct dealings between parties. Smart contracts remove the need
for intermediaries and allow for transparent, direct relationships with customers.
3. Reduce fraud: Fraudulent activity detection and reduction. Smart contracts are stored in
the blockchain.
4. Fault-tolerance: Since no single person or entity is in control of the digital assets, one-
party domination and situation of one part backing out do not happen as the platform is
decentralized and so even if one node detaches itself from the network, the contract
remains intact.
5. Cost-efficiency: The application of mart contracts eliminates the need for intermediaries
leading to reduced costs. Also eliminates paperwork leading to paper saving and money-
saving.
Solidity Language
Def : Solidity is a 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.
➢ It's used to create smart contracts that implement business logic and generate a
chain of transaction records in the blockchain system.
➢ It acts as a tool for creating machine-level code and compiling it on the Ethereum
Virtual Machine (EVM).
➢ It has a lot of similarities with C and C++ and is pretty simple to learn and understand.
For example, a “main” in C is equivalent to a “contract” in Solidity.
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 can be used to creating contracts like voting, blind auctions, crowdfunding,
multi-signature wallets, etc.
DataTypes of solidity:
➢ Solidity is a statically typed language, which implies that the type of each of the variables
should be specified.
➢ Data types allow the compiler to check the correct usage of the variables.
➢ The declared types have some default values called Zero-State, for example for bool the
default value is False.
Value Types:
➔ Value-type variables store their own data. These are the basic data types provided by
solidity. These types of variables are always passed by value. The variables are copied
wherever they are used in function arguments or assignments. Value type data types in
solidity are listed below:
1. Boolean: This data type accepts only two values True or False.
2. Integer: This data type is used to store integer values, int and uint are used to
declare signed and unsigned integers respectively.
3. Fixed Point Numbers: These data types are not fully supported in solidity yet, as
per the Solidity documentation. They can be declared as fixed and unfixed for
signed and unsigned fixed-point numbers of varying sizes respectively.
4. Address: Address hold a 20-byte value which represents the size of an
Ethereum address. An address can be used to get balance or to transfer a
balance.
5. Enums: It is used to create user-defined data types, used to assign a name to an
integral constant which makes the contract more readable, maintainable, and less
prone to errors. Options of enums can be represented by unsigned integer values
starting from 0.
How to execute code in solidity language
You can execute a Solidity Program in two ways -
1. Offline Mode
2. Online Mode
1.Offline:
Conditions
1. Download and install node.js.
2. Install Truffle globally.
3. Install ganache-cli.
2.Online : In the Online Mode, the Remix IDE is typically used to compile and run Solidity
smart contracts
Advantages of Solidity Language
1. Apart from fundamental data types, Solidity programming also allows complex
data types and member variables.
2. It provides an Application Binary Interface (ABI) to enable type safety. If the
compiler discovers a data type mismatch for any variable, the ABI generates an
error.
3. It refers to the ‘Natural Language Specification,' which is used to turn user-centric
specifications into language that machines can understand.
Example:
// Solidity program to
// demonstrate how to
// write a smart contract
pragma solidity >= 0.4.16 < 0.7.0; //Version Pragma
// 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;
}
}

You might also like