Deploying Smart Contracts for Hyperledger Fabric Enterprise Blockchain Platform

Two people surrounded by Hyperledger logo, Ethereum logo, and a contract

Despite probable skepticism, blockchain technology continues to build a reputation as an innovation that improves banking, finance, supply chain, and many other areas. Hyperledger Fabric ensures a smooth transition for enterprises into this emerging technology.

When you hear the word “blockchain”, Bitcoin and Ethereum immediately come to mind. These two platforms are well known in the DTL community. Their success and popularity have in some ways influenced the fact that many people associate blockchain with crypto transactions.

The Hyperledger project in general, and Hyperledger Fabric in particular, completely break this stereotype. They provide enterprises with all the necessary tools to build their own blockchain network with high security, performance, and confidentiality.

But why do you even need enterprise blockchain, and what exactly can Hyperledger do for your business? Get ready to dive into this technology and have all your questions answered.

Blockchain for businesses: what’s so special about it?

First, we’ll take a quick look at the basics, or rather the blockchain models. This knowledge will help you understand their core differences and decide which one is best for your business.

Blockchain models at a glance

There are two fundamentally different blockchain types: permissioned and permissionless.

A permissionless blockchain can also be called “public”, as you don’t need permission to become a part of a network and access the data that’s stored on the blockchain. Ideally, anyone can enter it, and no authority controls the entire system. Bitcoin and Ethereum are probably the most popular examples of permissionless blockchain.

However, what is good for some may not always work for others. A permissioned blockchain is known as a private network, and you need the owner’s permission to join it (logical, right?). It is up to them to decide who to grant access to.

The second type is obviously more suitable for enterprises, as only a limited number of entities should have access to internal information. Moreover, permissioned blockchains are faster and more efficient and, thanks to blockchain’s transparency, they increase trust between participants as well.

This blockchain model has already become popular with logistics companies, supply chain managers, banks, retailers, telecom firms, and many other businesses.

In detail: what does enterprise blockchain have to offer?

Since it’s clear that permissionless blockchains can be quite impractical for enterprise needs, let’s move on and see how permissioned enterprise blockchain solutions can serve businesses and streamline their workflows.

Permissioned enterprise blockchains are aimed to ensure higher energy efficiency, increased privacy, and better data security. Compared to public blockchains, they guarantee reduced network volatility and a reliable workflow organization. By implementing them, companies also lower their maintenance costs, minimize transaction commissions, and protect themselves from hacker attacks.

What else? Most financial institutions have to perform thousands of transactions per second. To meet the requirements of banks, telecom companies, and a wide range of other businesses, blockchain implements an architectural approach that ensures high performance and efficient separation of the various tasks.

Robust blockchain solutions implement asynchronous flows, fast consensus protocols and parallelization, deploys clustered ordering services, and executes itself in optimized environments.

Hyperledger Fabric as a key enterprise blockchain

A person leans on an hourglass and using a laptop next to Hyperledger icon

Let’s go back to February 2016 when the Linux Foundation launched a large-scale project called Hyperledger. The company, with its 30 founding corporate members, was aiming to improve blockchain technology and make it much more available to businesses. The founding members included big names such as IBM, SWIFT, ConsenSys, Guardtime, Calastone, VMware, Blockchain, R3, Cisco, Hitachi, Intel, J.P. Morgan, and others.

Today, this umbrella project of open-source blockchains and related tools is set to transform blockchain technology and make it more powerful and high performing.

One of the most notable and popular frameworks for blockchain-based enterprise solutions development is Hyperledger Fabric. The platform was first released in 2016 and has had several updates since then. Basically, Fabric is an open-source framework that can be used to create a permissioned blockchain. According to 2021 survey, Hyperledger fabric is the most useful and effective blockchain framework for various industries in comparison with similar ones (e.g. Ethereum, R3 Corda, Quorum).

There are several good reasons why we refer to Fabric as a key enterprise blockchain. Unlike other blockchain platforms, Hyperledger Fabric is designed ONLY for enterprise needs and doesn’t involve any cryptocurrency. It allows businesses to build high-performance and scalable blockchain solutions with high levels of confidentiality and trust.

We’ve also prepared a short explanatory video dedicated to the Hyperledger project. Check it out to get a basic understanding of the project, examine the functionality of its platforms, and find out what the prospects for Hyperledger are.

Fabric’s advantages

Below we delve deeper into this platform’s characteristics. Being a major enterprise blockchain, Hyperledger Fabric has numerous pros and a few cons.

  • Modularity

The first advantage of the platform is its modular architecture that is extremely helpful for developers who work on blockchain network implementation.

  • Speed

Public blockchains often show slow transaction processing. For example, Bitcoin performs an average of 7 transactions per second (tps). Hyperledger Fabric, by contrast, delivers over 3,500 tps, a key measure for companies dealing with an immense number of financial operations.

  • Smart contracts

The core of Hyperledger Fabric is represented by smart contracts and the ledger. Hyperledger smart contracts are often called “chaincode” and these terms are usually used interchangeably. However, “a smart contract is a domain-specific program which relates to specific business processes, whereas a chaincode is a technical container for a group of related smart contracts”.

In general, smart contracts allow community members to automate their transactions, make their network a more secure place, and eliminate costs associated with contracting.

  • Privacy

Company information and its transactions are commonly strictly confidential, so security comes first when choosing an enterprise solution.

How does it work with Fabric? The platform offers to create private channels for specific network members who can then handle their transactions and exchange sensitive information. Unauthorized members won’t be able to access that data. This functioning model is undoubtedly a big advantage for highly regulated industries.

  • Security

One more feature that helps protect keys and confidential data is the Hardware Security Model (HSM). HSM provides additional hardware-based security for digital signatures and can be utilized for identity management as well.

Many IT giants like Hitachi, IBM, Intel, Fujitsu Limited, and others have already joined and contributed to the Hyperledger project development, including the Fabric framework. Also, a growing developer community constantly strives to improve the platform. Thus, despite some problems that need to be fixed over time, Hyperledger Fabric continues to refine itself.

However, there are still a few little flies in the ointment. The platform’s features and work principles sound very promising for many, but enterprises need more proven use cases. Another challenge is to find skilled developers who can implement a Fabric-based solution according to the enterprise’s specific needs.

Find out how we can tune Hyperledger Fabric exactly to your business needs

Fabric’s use cases

What can tell you more about the technology than the fact that a number of world-renowned companies are already using it? Hyperledger Fabric has become the foundation for applications and solutions that are currently utilized by many business giants.

A person using a laptop surrounded by the icons of the industry spheres

Customer reward program

American Express has developed a blockchain solution using Hyperledger Fabric to upgrade its customer reward program. When a merchant makes a purchase, the blockchain stores the associated transaction details and tokenizes the data. Smart contracts generate and award points that are later added to the loyalty system.

Confidentiality was the only concern before the solution was implemented. Since Hyperledger Fabric provides each customer with a separate channel, others can’t access and view their transaction data. So the American Express workers had no need to worry.

Aviation marketplace

Honeywell, a global provider of avionics, engines, systems, and services was eager to open up a modern B2B Amazon-like market for used aircraft parts, as the existing systems were quite outdated.

As a result, they created GoDirect Trade, a marketplace where all transactions are recorded on a blockchain that’s built using Hyperledger Fabric. The project was very successful, with sales of $4 million in less than a year, more than 50 vendors attracted to it, and purchase times reduced to minutes.

Supply chain

Walmart was looking for ways to update their supply chain system to enhance transparency and trust between participants. Their objective was to handle the problem of foodborne disease outbreaks.

Through completing two pilot projects, Walmart made sure that blockchain could cater perfectly to the food industry. The Hyperledger Fabric based system made it possible to track foods within seconds and thus streamline food recall processes.

MineHub in collaboration with KrypC utilizes Hyperledger Fabric to make it possible for large companies to exchange data in a private and secure way. Up to $1.8 trillion of metals and minerals are transported daily, going through various traffic arteries, ports, railways, and warehouses causing a great amount of paperwork and verification procedures. MineHub is a blockchain-run platform providing mining and metals supply chain participants access to the information about the origin of the materials and real-time transportation details thus enhancing the shipment and strengthening trust between the parties involved.

Hyperledger Fabric has also been implemented by leading cloud service providers such as Alibaba, Amazon Web Services, Baidu, Huawei, IBM, Microsoft Azure, Oracle, and Tencent.

Finance

Visa uses Hyperledger Fabric for bank-to-bank transactions. B2B Connect tokenizes personal data about banks’ clients and stores it on a distributed ledger. Thus, global transactions are conducted securely with a significantly decreased possibility of fraud and a much higher speed.

The world’s first blockchain trade finance platform, we.trade, uses distributed ledger technology and smart contracts to ensure safe financial transactions between enterprises with the help of Hyperledger Fabric. Fabric’s modular architecture makes it possible to customize the platform according to the needs of a particular business and add features like transaction isolation and off-chain data storage. Blockchain also makes the transaction process smoother and more transparent.

How do smart contracts fit in?

To explain the meaning and purpose of smart contracts, first, we’ll remind you what ordinary contracts are about. These are paper-based and hand-signed agreements that contain excessive text written in an official manner. Not that we loved reading them in the 21st century.

Now let’s meet a smart contract – a self-executing digital brother of a conventional contract, where the agreement’s terms and conditions are code-programmed.

How it all began

The idea of smart contracts was originally proposed by the American computer scientist Nick Szabo back in 1994. But it only became a reality much later, after blockchain technology had continued evolving. Szabo described smart contracts as computerized transaction protocols that fulfill the contracts’ terms.

How it operates

Smart contracts are embedded in a distributed blockchain network. Once a transaction proceeds and smart contracts are deployed, the code becomes immutable. Consequently, transactions become irreversible, as well as the information about them.

Hyperledger Fabric is one of four Hyperledger platforms that support smart contracts. Fabric uses installed smart contracts, which means that before the network goes live, they deploy business logic into the network’s validators.

We hope you still remember that Hyperledger’s smart contract is related to chaincode – a program responsible for managing the ledger’s state through the operations that get sent by applications. The network participants usually agree upon some specific business logic, and then a chaincode handles it.

What’s the need for smart contracts?

A person wearing business suit standing next to a contract

Let’s start with a few facts: smart contracts are required in the blockchain platform architecture, and they are already used in many industries. Now it’s time to explain why.

The benefits of smart contracts

Anyone ever made serious purchases with loans? If yes, you’ll remember the process. It involves piles of paperwork, contacting intermediaries, filling out forms, and waiting for a “yes” from the bank. All these procedures are time-consuming and often result in additional financial costs. Why does it have to be so complicated? The reason is that the parties don’t trust each other and ask to verify everything before handling a large transaction.

Smart contracts, in their turn, verify each member’s identity, digitize it, and store it on the blockchain. This way, even if the network members don’t know each other personally, they can still trust the system where each participant is authenticated and authorized. Hence, the involvement of intermediaries is no longer required, and the parties save time and money when handling transactions.

To sum it up, smart contracts transform transaction procedures into a direct peer-to-peer process that is also more secure, tamper-resistant, cost-effective, and time-efficient.

Smart contracts: applicable to various industries

Multiple industries can streamline their workflows by implementing smart contracts. The first and most obvious sphere of adoption is banking where smart contracts can save costs processing loans and conducting other financial operations.

Smart contracts are intended to increase trust in the insurance industry. Insurance companies obtain a tool that can verify whether claims from their clients are true or false. Meanwhile, customers can make sure that firms will pay the right amount of money when an insured event occurs.

We need to talk about health insurance as well. The health insurance system causes headaches for many, right? You may have experienced wasting your time filling in bulky insurance claim forms and even faced fraud cases, so smart contracts are very helpful here.

Wondering how it works? First, the patient acquires insurance backed by smart contracts. In this case, all data is automatically protected in their profile and stored on the blockchain. If a patient seeks medical help, the smart contract is triggered automatically, and money from the insurance company goes directly to the hospital. So there are no delays, and you can pay effortlessly for medical services.

Smart contracts also apply to medical records. Conventional databases can be outdated, not to mention hospitals that still keep records on paper. The data, again, can be stored in a digital ledger and viewed by patients and doctors. The use of smart contracts allows you to move from one hospital to another without filling out forms.

It will also become much easier for you to visit any clinic in the world. You give the doctor your private key and they will see your medical history, allergies, lab tests, and so on.

Energy is another area where smart contracts can bring innovation. Based on blockchain, they create an opportunity for decentralized energy management and trading, making these processes easier and more efficient. Moreover, smart contracts can perform trustworthy transactions without involving a third party.

Apart from the use cases already mentioned, smart contracts are able to transform areas like real estate, voting, medical research, supply chain management, authorship, intellectual property rights, gaming, and many more.

Designing applications with smart contracts

Smart contracts can be implemented in applications with the use of Hyperledger frameworks and tools. Hyperledger smart contracts are utilized to design applications to support various business operations and transactions.

Here we take a closer look at the Hyperledger Fabric framework and its own native smart contracts which play such a key role in this blockchain-based system.

How do smart contracts work? Typically, there are two methods of developing smart contracts using Fabric. You can either code contracts one by one into separate chaincode instances, or use one chaincode to manage all contracts and provide an API to handle their lifecycle.

Ethereum is yet another popular open-source platform that can be used to build apps with smart contract functionality. However, this blockchain system and its smart contracts serve completely different purposes.

Check out how this real application built on Hyperledger Fabric works

Ethereum smart contracts vs Fabric’s chaincode

Two people pointing on Ethereum logo

Businesses that require innovation and automation can greatly benefit from blockchain technology and embedded smart contracts. Hyperledger or Ethereum smart contracts are designed to simplify financial transactions, authenticate products, and verify insurance claims, and they can streamline a wide range of business processes.

Fabric and Ethereum smart contracts: main differences and similarities

Here’s one thing they have in common: Ethereum and Hyperledger smart contracts are both open-source, which means they have accessible code that anyone can view, change, and improve in line with their own requirements.

One major distinction between smart contracts on these two blockchains comes from their purpose. Since Hyperledger Fabric caters to the needs of enterprises, permissioned smart contracts are applicable here. Even if you get permission to become a blockchain system member, you may still not see all the data and transactions, because Hyperledger Fabric provides multi-level access to keep certain information confidential.

Ethereum, on the other hand, is a public blockchain network that’s especially suitable for building decentralized payment applications. Accordingly, smart contracts in Ethereum are permissionless, public, and open to everyone. This feature particularly benefits public systems and contributes to their reliability and overall accountability.

Another big difference is cryptocurrency. While Hyperledger is cryptocurrency independent, Ethereum has its own crypto called Ether (ETH).

Why do we need Ethereum smart contracts on Fabric?

Despite the fact that these systems serve different purposes and they are both popular in their fields, Ethereum was launched several years earlier than Hyperledger, and the platform together with its smart contracts has become a milestone in blockchain history.

Since Ethereum has been around for a very long time, there are programmers who are well versed in developing Ethereum smart contracts using the Solidity programming language. At the same time, Fabric’s chaincode requires knowledge of Golang and Node.js. Thus, developers accustomed to working with Ethereum and Solidity won’t be able to write smart contracts for Hyperledger Fabric.

Many commented that the impossibility to build Ethereum smart contracts was a major drawback of Fabric. Now the platform supports Ethereum Virtual Machine (EVM) bytecode smart contracts, allowing multiple developers to implement Ethereum smart contracts for Fabric.

How to deploy Ethereum smart contracts on Hyperledger Fabric

Initially, one could build chaincode with Golang, Java, JavaScript, and Node.js. Now, developers can use Solidity and Vyper to create Ethereum smart contracts on Fabric.

Now we are going to describe the process of setting up Ethereum smart contracts on Hyperledger Fabric.

Before moving on to the contract deployment instructions, we’ll name the components that help support Ethereum smart contracts. Those are Ethereum Virtual Machine (EVM), Externally Owned Accounts (EOAs), Contract Accounts (CAs), gas (a fee for any transaction on Ethereum), and Ethereum client. For the last one, Ethereum developers use Web3.js to communicate with Ethereum blockchain, while implementing Fab3 for Fabric. Fab3 ensures Hyperledger Fabric EVM implementation in part, while Ethereum applies to the TestRPC Ethereum client.

Set-up process

Two people operating a guideline next to a laptop

Step 1. Install the Prerequisites: Samples, Binaries, Docker Images, and other required tools.

Here is your checklist:

  • Download the latest version of the cURL tool.
  • Install Docker and Docker Compose. The first of these is utilized to design a full package for an application, and the second tool serves to define and launch multi-container apps.
  • Set up the GO programming language (it is used for multiple Fabric components).
  • By leveraging Node.js, you will also install NPM.
  • If you’re an Ubuntu 16.04 user, you will need Python 2.7.

Step 2 (optional). Do several configurations to instantiate the EVM chaincode.

First, navigate to the “first-network” folder in “fabric-samples” and make small changes in the “docker-compose-CLI.yaml” file. Then, you need to start the network, go into the CLI Docker container, and install the EVM chaincode. There you have it: the EVM chaincode is now instantiated.

Step 3. Install Hyperledger Fabric EVM chaincode

The EVM chaincode we need is based on the Hyperledger Burrow. This chaincode will enable you to utilize Fabric’s permissioned blockchain platform and interact with Ethereum smart contracts. It is possible to achieve integration through Fab3 and the EVM chaincode. You can find detailed instructions here.

Step 4. Build Solidity smart contracts on Remix IDE without installing anything else.

This open-source web and desktop app can be used throughout the entire contract development path. If this resource is new to you, you can study the Remix documentation first.

Step 5. The last thing to do is to compile and deploy Ethereum smart contracts.

Start compiling on Remix, click and copy the Bytecode, paste it into any text editor, and the copied text will appear as a JSON document. To install the bytecode within the Fabric EVM and actually deploy the smart contracts, you will need to follow the “peer chaincode invoke” process.

Those are the main steps that must be taken while setting up Ethereum smart contracts on Hyperledger Fabric.

Find more details in the smart contract on Hyperledger or follow the tutorial. Once you review all the documentation and follow these steps, you will be able to uncover all the possibilities that underlie this Hyperledger project.

Conclusion

Over the years of its existence, the still-young Hyperledger Fabric platform has managed to find its own niche in the blockchain world and almost catch up in popularity with Bitcoin and Ethereum. If you are not interested in introducing cryptocurrency into your business workflows but excited to discover blockchain opportunities for your enterprise, Hyperledger Fabric is by far the best choice.

Smart contracts and chaincode are big reasons why enterprises consider and build solutions based on this platform. They automate transactions, verify network members’ identities, and keep sensitive information confidential.

Since Fabric now also supports Ethereum smart contracts, its capabilities are even broader. We’ll be honest with you: developing applications with Ethereum smart contracts on Hyperledger Fabric is not an easy task, especially for someone with little or no technical background. By partnering with an experienced developer, you can avoid all that hassle.

Blockchain development specialists will advise you on the feasibility of the technology and create an application that can easily solve any complex business problem.

Get updates about blockchain, technologies and our company

We will process the personal data you provide in accordance with our Privacy policy. You can unsubscribe or change your preferences at any time by clicking the link in any email.

Follow us on social networks and don't miss the latest tech news

  • facebook
  • twitter
  • linkedin
  • instagram
Stay tuned and add value to your feed