Convert Figma logo to code with AI

hyperledger logofabric

Hyperledger Fabric is an enterprise-grade permissioned distributed ledger framework for developing solutions and applications. Its modular and versatile design satisfies a broad range of industry use cases. It offers a unique approach to consensus that enables performance at scale while preserving privacy.

15,696
8,833
15,696
183

Top Related Projects

Go implementation of the Ethereum protocol

3,987

Corda is an open source blockchain project, designed for business from the start. Only Corda allows you to build interoperable blockchain networks that transact in strict privacy. Corda's smart contract technology allows businesses to transact directly, with value.

4,676

A permissioned implementation of Ethereum supporting data privacy

Substrate: The platform for blockchain innovators

11,273

An open source smart contract platform

⟁ Tendermint Core (BFT Consensus) in Go

Quick Overview

Hyperledger Fabric is an open-source enterprise-grade permissioned distributed ledger technology (DLT) platform. It is designed to support modular architecture with plug-and-play components, such as consensus and membership services. Fabric is optimized for a broad range of industry use cases, including finance, healthcare, and supply chain.

Pros

  • Highly modular and configurable architecture
  • Supports private and confidential transactions
  • Provides high performance and scalability
  • Enables smart contracts (chaincode) in multiple programming languages

Cons

  • Steep learning curve for newcomers
  • Complex setup and deployment process
  • Limited public documentation and examples compared to some blockchain platforms
  • Requires careful design and implementation to ensure security

Code Examples

  1. Initializing a Fabric client:
const { Gateway, Wallets } = require('fabric-network');

async function initFabricClient() {
    const wallet = await Wallets.newFileSystemWallet('./wallet');
    const gateway = new Gateway();
    await gateway.connect(connectionProfile, {
        wallet,
        identity: 'user1',
        discovery: { enabled: true, asLocalhost: true }
    });
    return gateway;
}
  1. Invoking a chaincode function:
async function invokeChaincode(gateway, channelName, chaincodeName, functionName, args) {
    const network = await gateway.getNetwork(channelName);
    const contract = network.getContract(chaincodeName);
    const result = await contract.submitTransaction(functionName, ...args);
    return result;
}
  1. Querying the ledger:
async function queryLedger(gateway, channelName, chaincodeName, queryString) {
    const network = await gateway.getNetwork(channelName);
    const contract = network.getContract(chaincodeName);
    const result = await contract.evaluateTransaction('query', queryString);
    return JSON.parse(result.toString());
}

Getting Started

To get started with Hyperledger Fabric:

  1. Install prerequisites (Docker, Docker Compose, Go, Node.js)
  2. Clone the Fabric samples repository:
    git clone https://github.com/hyperledger/fabric-samples.git
    
  3. Navigate to the test-network directory:
    cd fabric-samples/test-network
    
  4. Start the test network:
    ./network.sh up createChannel -c mychannel -ca
    
  5. Deploy a sample chaincode:
    ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
    

This sets up a basic Fabric network with two organizations and deploys a sample chaincode. For more detailed instructions and advanced usage, refer to the official Hyperledger Fabric documentation.

Competitor Comparisons

Go implementation of the Ethereum protocol

Pros of go-ethereum

  • Public, permissionless blockchain with a large, active community
  • Native cryptocurrency (Ether) and robust support for smart contracts
  • Widely adopted and battle-tested in production environments

Cons of go-ethereum

  • Lower transaction throughput compared to Fabric
  • Higher energy consumption due to Proof-of-Work consensus (pre-Merge)
  • Less flexibility in terms of privacy and access control

Code Comparison

go-ethereum (Solidity smart contract):

pragma solidity ^0.8.0;

contract SimpleStorage {
    uint256 private storedData;

    function set(uint256 x) public {
        storedData = x;
    }

    function get() public view returns (uint256) {
        return storedData;
    }
}

Fabric (Chaincode in Go):

package main

import (
    "fmt"
    "github.com/hyperledger/fabric-contract-api-go/contractapi"
)

type SimpleAsset struct {
    contractapi.Contract
}

func (t *SimpleAsset) Set(ctx contractapi.TransactionContextInterface, key string, value string) error {
    return ctx.GetStub().PutState(key, []byte(value))
}

func (t *SimpleAsset) Get(ctx contractapi.TransactionContextInterface, key string) (string, error) {
    value, err := ctx.GetStub().GetState(key)
    if err != nil {
        return "", fmt.Errorf("failed to read from world state: %v", err)
    }
    return string(value), nil
}
3,987

Corda is an open source blockchain project, designed for business from the start. Only Corda allows you to build interoperable blockchain networks that transact in strict privacy. Corda's smart contract technology allows businesses to transact directly, with value.

Pros of Corda

  • Designed specifically for financial services, with built-in privacy and regulatory compliance features
  • Supports multiple consensus mechanisms, allowing for more flexibility in network design
  • Uses a unique "flow framework" for coordinating complex, multi-party transactions

Cons of Corda

  • Smaller community and ecosystem compared to Fabric
  • Steeper learning curve due to its specialized nature and use of Kotlin
  • Limited support for smart contracts written in languages other than Java or Kotlin

Code Comparison

Fabric (Chaincode in Go):

func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, value int) error {
    asset := Asset{ID: id, Value: value}
    assetJSON, err := json.Marshal(asset)
    if err != nil {
        return err
    }
    return ctx.GetStub().PutState(id, assetJSON)
}

Corda (Flow in Kotlin):

@Suspendable
override fun call(): SignedTransaction {
    val notary = serviceHub.networkMapCache.notaryIdentities.first()
    val txBuilder = TransactionBuilder(notary)
    .addOutputState(AssetState(value, ourIdentity), AssetContract.ID)
    .addCommand(AssetContract.Commands.Create(), ourIdentity.owningKey)
    val signedTx = serviceHub.signInitialTransaction(txBuilder)
    return subFlow(FinalityFlow(signedTx, listOf()))
}
4,676

A permissioned implementation of Ethereum supporting data privacy

Pros of Quorum

  • Built on Ethereum, leveraging its extensive ecosystem and tooling
  • Supports both public and private transactions within the same network
  • Offers multiple consensus mechanisms (RAFT, IBFT, Clique)

Cons of Quorum

  • Less modular architecture compared to Fabric
  • Limited support for complex smart contract languages beyond Solidity
  • Smaller community and fewer enterprise-grade deployments

Code Comparison

Fabric (Chaincode in Go):

func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, value int) error {
    asset := Asset{ID: id, Value: value}
    assetJSON, err := json.Marshal(asset)
    if err != nil {
        return err
    }
    return ctx.GetStub().PutState(id, assetJSON)
}

Quorum (Smart Contract in Solidity):

pragma solidity ^0.8.0;

contract AssetManager {
    mapping(string => uint256) private assets;

    function createAsset(string memory id, uint256 value) public {
        assets[id] = value;
    }
}

Both Fabric and Quorum are enterprise-focused blockchain platforms, but they differ in their approach and underlying technology. Fabric offers a more modular and flexible architecture, while Quorum builds upon the Ethereum ecosystem. The choice between them depends on specific project requirements and existing technology stacks.

Substrate: The platform for blockchain innovators

Pros of Substrate

  • More flexible and customizable blockchain framework
  • Easier to develop and deploy custom blockchains
  • Better suited for building interoperable blockchain networks

Cons of Substrate

  • Steeper learning curve due to its complexity
  • Less mature ecosystem compared to Fabric
  • Fewer enterprise-focused features out of the box

Code Comparison

Substrate (Rust):

#[pallet::weight(10_000)]
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
    let who = ensure_signed(origin)?;
    <Something<T>>::put(something);
    Self::deposit_event(Event::SomethingStored(something, who));
    Ok(())
}

Fabric (Go):

func (s *SmartContract) DoSomething(ctx contractapi.TransactionContextInterface, something string) error {
    err := ctx.GetStub().PutState("something", []byte(something))
    if err != nil {
        return fmt.Errorf("failed to put to world state: %v", err)
    }
    return nil
}

The code snippets demonstrate the different approaches to implementing smart contract logic in Substrate and Fabric. Substrate uses Rust and a more declarative style, while Fabric uses Go and a more imperative approach.

11,273

An open source smart contract platform

Pros of EOS

  • Higher transaction throughput and scalability
  • More user-friendly for developers with WebAssembly support
  • Faster block confirmation times (0.5 seconds)

Cons of EOS

  • More centralized governance model
  • Limited privacy features compared to Fabric
  • Potential for network congestion during high-demand periods

Code Comparison

EOS (C++):

#include <eosio/eosio.hpp>

class [[eosio::contract]] hello : public eosio::contract {
public:
    [[eosio::action]]
    void hi(name user) {
        print("Hello, ", user);
    }
};

Fabric (Go):

func (s *SmartContract) Hello(ctx contractapi.TransactionContextInterface, name string) error {
    return ctx.GetStub().PutState("greeting", []byte("Hello, "+name))
}

Key Differences

  • EOS uses C++ for smart contracts, while Fabric supports multiple languages (Go, Java, JavaScript)
  • EOS focuses on high-performance public blockchains, whereas Fabric is designed for permissioned enterprise networks
  • EOS uses a Delegated Proof-of-Stake consensus mechanism, while Fabric offers pluggable consensus protocols

Use Cases

  • EOS: Decentralized applications (dApps) with high transaction volumes, gaming, social media
  • Fabric: Supply chain management, financial services, healthcare data sharing

⟁ Tendermint Core (BFT Consensus) in Go

Pros of Tendermint

  • Simpler architecture and easier to understand
  • Better performance and scalability for high-throughput applications
  • More flexible consensus mechanism, allowing for various voting power distributions

Cons of Tendermint

  • Less mature ecosystem and enterprise adoption compared to Fabric
  • Fewer built-in privacy features and permissioning options
  • Limited smart contract support out of the box

Code Comparison

Tendermint (Go):

func (app *KVStoreApplication) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {
    key, value := req.Tx[:32], req.Tx[32:]
    app.state.Set(key, value)
    return abci.ResponseDeliverTx{Code: 0}
}

Fabric (Go):

func (s *SmartContract) Invoke(ctx contractapi.TransactionContextInterface) error {
    _, args := ctx.GetStub().GetFunctionAndParameters()
    err := ctx.GetStub().PutState(args[0], []byte(args[1]))
    return err
}

Both examples show simple key-value storage operations, but Fabric's approach is more abstracted and integrated with its chaincode concept, while Tendermint's is more direct and lower-level.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Hyperledger Fabric

OpenSSF Scorecard CII Best Practices Go Report Card GoDoc Documentation Status GitHub Actions Workflow Status GitHub Actions Workflow Status Security vulnerability scan GitHub go.mod Go version GitHub Release

Overview

Hyperledger Fabric is a Graduated project under the Hyperledger umbrella, designed for distributed ledger solutions. Its modular architecture provides high levels of confidentiality, resiliency, flexibility, and scalability. Hyperledger Fabric allows for pluggable implementations of various components, accommodating the complexities of different economic ecosystems.

This platform offers a uniquely elastic and extensible architecture, setting it apart from other blockchain solutions. Building on a fully-vetted, open-source framework, Hyperledger Fabric is an ideal starting point for enterprise blockchain initiatives.

Releases

Hyperledger Fabric provides periodic releases with new features and improvements. Certain releases are designated as Long-Term Support (LTS), ensuring that important fixes are backported during overlap periods.

Current LTS Release:

Historic LTS Releases:

  • v2.2.x (maintenance ended February 2024)
  • v1.4.x (maintenance ended April 2021)

For complete release notes, visit the GitHub releases page.

Documentation and Getting Started

To familiarize yourself with Hyperledger Fabric, visit our comprehensive online documentation:

We recommend that first-time users start with the Getting Started section to understand the components and basic transaction flow.

Contributing

We welcome contributions to Hyperledger Fabric in various forms. There’s always plenty to do! Check our contribution guidelines for more details on how to get involved.

Community

Engage with the Hyperledger community:

License

Hyperledger Fabric source code is available under the Apache License, Version 2.0 (Apache-2.0), and documentation files are under the Creative Commons Attribution 4.0 International License (CC-BY-4.0).

NPM DownloadsLast 30 Days