Hyperledger Fabric smart contract platform
Discover an enterprise-grade framework promoting smart contract adoption around the world. Hyperledger Fabric, an open-source environment launched by Linux, stands out due to its modular architecture and permissioned nature. It takes access control to the next level. Here is how this distributed ledger network works, and why the attention it gets is fully merited.
History and concept
The Linux Foundation launched its modular framework in December 2015. It solves a fundamental problem for businesses – the need for distributed databases trusted by all members. The Hyperledger solutions, which are also supported by IBM and Intel, combine high security and transparency with peer-to-peer efficiency and collaborative design.
In 2020, the framework was reinvented as Fabric 2.0 to offer enhanced smart contracts and transaction data sharing. According to IBM, it can handle over 3,500 TPS with a latency of less than one second. Developers and researchers are working on expanding the throughput. For example, a team at the University of Waterloo has re-engineered the network to reach nearly 20,000 TPS.
Benefits of Hyperledger Fabric network
With this platform, corporations kill two birds with one stone – leverage blockchain architecture while ensuring data privacy. It has been adopted by over 200 members, including giants like Walmart, Visa, FedEx, and Huawei. Here are the top four advantages for industrial use, from healthcare to manufacturing to finance.
The Linux Foundation, which hosts the framework, has been a leader in open-source technologies since the 1990s. Hyperledger Fabric's community includes over 120,000 contributing organizations and over 15,000 engineer contributors. All projects are free to download and use.
Anyone can contribute to the codebase or become its maintainer. The community also elects developers for the Technical Steering Committee that makes technical decisions. The elected members of the Hyperledger Governing Board deal with fund management matters.
This network requires that the identity of every participant is authenticated. Thus, Hyperledger Fabric can benefit any supply chain, from banking to healthcare. Any environment with restricted data exposure can benefit from its architecture. For instance, insurance firms maintain customer privacy as only permissioned parties can access their claim data.
Governance and access control
This framework was designed with private and confidential transactions in mind. True to its name, it is formed by channels for transactions between two or more network members. Each of these threads or private subnets requires party authentication and authorization.
Thereby, Hyperledger Fabric enhances access control, and it is particularly valuable for restricted data exposure. When rival businesses use the same network, they leverage this additional layer of protection. Meanwhile, the Private Data Collection feature set limits transaction access even further – to a subset of participating members.
Permissionless networks use transaction validation mechanisms that may slow them down. For example, this holds true for Byzantine Fault Tolerance. As Hyperledger Fabric was built for enterprise use, its consensus mechanism supports fast transactions and impressive throughput (more on this below).
How Hyperledger Fabric works
Businesses need confidential contracts and private transactions, but these are incompatible with conventional blockchains. Hyperledger Fabric is a scalable and secure solution to this problem. Enterprises leverage it to build industry-grade architectures.
This framework adapts the key features of blockchain use to corporate needs. The following elements allow it to provide reliable permission-based membership.
Transaction processing involves three stages. This separation makes the network more scalable. What's more, it reduces the number of trust levels and verification, thereby preventing clutter.
- Chaincode (smart contracts) containing distributed logic processing and system agreement
- Transaction ordering
- Transaction validation and commitment
Thanks to the modular structure, Hyperledger Fabric supports plug-and-play of components instead of building them from the ground up. Businesses reuse the existing features and integrate extra modules with ease. For example, to verify the identities of network participants, they only need to plug and reuse the corresponding module.
Consensus and roles of network participants
Like transaction processing, consensus also includes three stages. This distributed ledger system requires:
- Endorsement based on the policy agreed by the participants
- Ordering, which determines how the endorsed transactions are committed to the ledger
- Validation, which analyzes ordered blocks and validates their output, referring to the endorsement policy and checking for double-spending
This blockchain technology is very different from Ethereum. In permissionless environments, any node can contribute to the consensus process while transactions are ordered and grouped into blocks. On Hyperledger Fabric, transaction ordering is performed by orderer nodes that form an ordering service.
Peers execute and maintain a ledger of transactions. Due to the deterministic algorithm, any validated block is guaranteed to be correct. The network participants have two roles that can overlap, as you can see from the diagram above.
Every transaction is submitted to one or more endorser peers. This process is based on the endorsement policy. An endorser peer can also act as a committer (see below). In this ecosystem, each peer is a committer, but only some peers are endorsers.
Once endorsed, a transaction block is sent to committers. They check compliance with the endorsement policy and make sure there are no conflicting transactions. Valid transactions are then recorded in the channel-specific ledger.
Hyperledger Fabric improves security by protecting key data points. Meanwhile, only confirming instructions are transferred across the network, which boosts scalability and performance.
Smart contracts and chaincode
From an app developer's perspective, the core of Hyperledger Fabric comprises a ledger and smart contracts. The former contains facts about the present and past state of a specific group of business objects. Automatic contracts determine the transaction logic for new facts that end up in the ledger.
Although the terms smart contract and chaincode are used interchangeably, they denote different things. Chaincode is essentially a package for several self-executing agreements. The smart contract code is installed inside this container on an organization's peers. With its deployment, all contracts become available to the connected apps.
For example, an insurance chaincode may include four contracts representing its key aspects – policy, liability, syndication, and securitization. Meanwhile, a vehicle chaincode may comprise contracts for a car, a boat, and a truck, as shown in the following diagram.
Smart contracts are domain-specific programs that govern transactions. Chaincode determines how these programs are prepared for deployment. Aside from grouping related contracts, chaincode is used for low-level programming of Fabric.
Interactions between smart contract code and ledger
When a blockchain records new transactions, they update the states stored in the related ledger. Each smart agreement accesses its two components:
- a blockchain creating an immutable record of all transactions
- a world state containing the current value of these states in a cache
In relation to these components, smart contracts can perform four functions. First, they can query the record of transactions. Secondly, they may create, update, read, or delete business objects in the world state. The blockchain record of these changes remains immutable:
- Put states – create a new business object or modify an existing one
- Get states – send a query to retrieve data concerning the current state of a business object
- Delete states – remove a business object from the current state. This does not concern the ledger history.
Endorsement policy for smart contracts
Every chaincode comes with a set of rules governing smart contracts within it. This policy is of paramount importance. It determines which network participants (organizations) must sign a contract-generated transaction to validate it.
For instance, in a network with four participants, only three of them may be obliged to sign a transaction. In case of multiple signees, the contract must be executed by a sufficient number of parties. While all transactions are imprinted on the ledger, only valid ones update the world state.
In the diagram above, you can see that both the seller organization and the buyer organization must sign and execute the transaction to transfer a vehicle. Only trusted parties must validate it. As a result, this blockchain technology models real-world interactions better than Bitcoin or Ethereum.
Other policies on Hyperledger Fabric
Hyperledger Fabric includes an array of other policies. All of them require agreement by the consortium within a blockchain network. These policies may specify:
- Parties that can update or query the ledger
- Parties that can add participants to the network
- Parties that can remove participants from the network
Policies may contain the rules for changing them. Companies may also customize their endorsement policies. For example, some use cases require checking that the transaction does not double-spend its inputs. Some arrangements require keeping the peer identity private — that is, ensuring that the signature and public key cannot be linked to it.
Channels on Hyperledger Fabric network
By joining multiple channels, an enterprise can participate in more than one blockchain network. It can join a network of networks where infrastructure is shared while data and communication privacy are both maintained.
Hyperledger Fabric balances separation and integration. On the one hand, it lets enterprises segregate their work traffic with counterparties. Each channel is a separate communication mechanism for specific organizations. On the other hand, its participants can coordinate independent activities when necessary.
Channel members must approve a chaincode definition for their enterprise – a struct with operation parameters – to make execution possible. Applications can access smart contracts once this definition is committed, which requires majority approval. Contract execution must comply with the endorsement policy contained in the definition (along with the name and version of the chaincode).
Look back at the vehicle channel illustrated above. The endorsement policy is specified in the chaincode definition of car. Transactions are invalid unless signed by both parties – the seller and the buyer. Both must also approve the chaincode definition, as the default rule requires that a majority of participants do so.
Meanwhile, in the insurance channel, only ORG3 is obliged to endorse a transaction. The same entity can participate in both networks and coordinate activity with the counterparties within them.
How to develop smart contracts
As we have mentioned, a chaincode can carry multiple smart contracts, and they become accessible once it is deployed. Thus, only administrators deal with chaincode – all the other participants work with smart contracts.
Implementing smart contracts
Deployment, which is performed via the Fabric chaincode lifecycle, involves four steps. This lets multiple organizations agree on their chaincode operation principles in advance.
- Packaging the smart contract
- Installing the chaincode package
- Approving a chaincode definition
- Committing the chaincode definition to the channel
Applications of Hyperledger Fabric in 2022
As a modular system, Hyperledger Fabric is extremely versatile. Companies from different industries can view the same immutable data. Accountability is enhanced while the risk of counterfeiting goes down. The existing applications include:
- supply chain track-and-trace (for example, diamond shipments and tracing the source of agricultural products)
- trade finance
- loyalty and rewards
- securing land registries
- clearing and settlement of financial assets
Projects built on Hyperledger Fabric take the form of permissioned DLT (decentralized ledger technology) platforms. They fall into two categories:
- Private – controlled by one entity
- Consortium – controlled by multiple entities
Over 500 applications have been built on this framework so far. One of the most prominent ones is IBM Food Trust. By connecting producers, suppliers, manufacturers, retailers, and other parties, it aims to provide a "smarter, safer, more sustainable food system for all."
Aside from Hyperledger Fabric, the community has developed 14 software projects, including other enterprise blockchain platforms. All of them are open source, so they are free to download and use without joining Hyperledger Foundation. The other graduated ecosystems are:
- Hyperledger ARIES – a shared tool kit for solutions that involve creating, transferring, and storing verifiable digital credentials
- Hyperledger BESU – an Ethereum client designed to be enterprise-friendly for both public and private permissioned network use cases
- Hyperledger INDY – a set of tools, libraries, and components for digital identities rooted in distributed ledgers with high interoperability
- Hyperledger IROHA – a complementary distributed ledger platform offering a development environment for C++ and mobile app developers
- Hyperledger SAWTOOTH – a modular platform for creating, deploying, and running distributed ledgers (blockchains)
The Linux Foundation offers a powerful blockchain framework for smart contract adoption by businesses. This open-source environment stands out by virtue of its modular architecture, security, and advanced access control. It packs related smart contracts into chaincode that can support an endless array of business processes. By guaranteeing the immutability of data, Hyperledger Fabric facilitates transactions and decision-making across enterprises and industries.