All Projects → hyperledger → Fabric Gateway Java

hyperledger / Fabric Gateway Java

Licence: other
Hyperledger Fabric Gateway SDK for Java https://wiki.hyperledger.org/display/fabric

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Fabric Gateway Java

Fabric Sdk Node
Hyperledger Fabric SDK for Node https://wiki.hyperledger.org/display/fabric
Stars: ✭ 676 (+454.1%)
Mutual labels:  blockchain, fabric, hyperledger, distributed-ledger, hacktoberfest
Fabric Sdk Java
Stars: ✭ 982 (+704.92%)
Mutual labels:  blockchain, fabric, hyperledger, distributed-ledger, hacktoberfest
Fabric Sdk Py
Hyperledger Fabric Python SDK
Stars: ✭ 303 (+148.36%)
Mutual labels:  blockchain, fabric, hyperledger, distributed-ledger
Fabric
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.
Stars: ✭ 12,911 (+10482.79%)
Mutual labels:  blockchain, fabric, hyperledger, distributed-ledger
Iroha Javascript
JavaScript library for Iroha, a Distributed Ledger Technology (blockchain) platform.
Stars: ✭ 77 (-36.89%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Composer Tools
⚠️ ⚠️ ⚠️ Hyperledger Composer has been deprecated ⚠️ ⚠️ ⚠️
Stars: ✭ 75 (-38.52%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Fabric Sdk Go
Stars: ✭ 712 (+483.61%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Iroha Ios
iOS Swift library for Iroha, a simple distributed ledger
Stars: ✭ 81 (-33.61%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Cello
Operating System for Enterprise Blockchain
Stars: ✭ 715 (+486.07%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Fabric Chaintool
Stars: ✭ 89 (-27.05%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Ergo
The Language for Smart Legal Contracts
Stars: ✭ 108 (-11.48%)
Mutual labels:  blockchain, hyperledger, hacktoberfest
Fabric Baseimage
Stars: ✭ 53 (-56.56%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Hyperledger
Hyperledger is a Collaborative Project at The Linux Foundation.
Stars: ✭ 3,653 (+2894.26%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Fabric Ca
Stars: ✭ 331 (+171.31%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Blockchain Explorer
Stars: ✭ 984 (+706.56%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Iroha Android
Android library for Iroha, a Distributed Ledger Technology (blockchain) platform.
Stars: ✭ 108 (-11.48%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
Mortgageblockchainfabric
Mortgage Processing App using Hyperledger Fabric Blockchain. Uses channels for privacy and access, and restricts read/write previleges through endorsement policies
Stars: ✭ 45 (-63.11%)
Mutual labels:  blockchain, fabric, hyperledger
Composer Sample Networks
⚠️ ⚠️ ⚠️ Hyperledger Composer has been deprecated ⚠️ ⚠️ ⚠️
Stars: ✭ 226 (+85.25%)
Mutual labels:  blockchain, hyperledger, distributed-ledger
hyperledger-fabric-sdk-php
Client SDK for Hyperledger Fabric for use in PHP applications
Stars: ✭ 40 (-67.21%)
Mutual labels:  fabric, hyperledger, distributed-ledger
Fabric Explorer
Fabric-explorer is a simple, powerful, maintainable, open source fabric explorer
Stars: ✭ 117 (-4.1%)
Mutual labels:  blockchain, fabric, hyperledger

Hyperledger Fabric Gateway SDK for Java

Branch Build status
master
release-2.2
release-1.4

The Fabric Gateway SDK allows applications to interact with a Fabric blockchain network. It provides a simple API to submit transactions to a ledger or query the contents of a ledger with minimal code.

The Gateway SDK implements the Fabric programming model as described in the Developing Applications chapter of the Fabric documentation.

How to use

The following shows a complete code sample of how to connect to a fabric network, submit a transaction and query the ledger state using an instantiated smart contract (fabcar sample).

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeoutException;

import org.hyperledger.fabric.gateway.Contract;
import org.hyperledger.fabric.gateway.ContractException;
import org.hyperledger.fabric.gateway.Gateway;
import org.hyperledger.fabric.gateway.Network;
import org.hyperledger.fabric.gateway.Wallet;
import org.hyperledger.fabric.gateway.Wallets;

class Sample {
    public static void main(String[] args) throws IOException {
        // Load an existing wallet holding identities used to access the network.
        Path walletDirectory = Paths.get("wallet");
        Wallet wallet = Wallets.newFileSystemWallet(walletDirectory);

        // Path to a common connection profile describing the network.
        Path networkConfigFile = Paths.get("connection.json");

        // Configure the gateway connection used to access the network.
        Gateway.Builder builder = Gateway.createBuilder()
                .identity(wallet, "user1")
                .networkConfig(networkConfigFile);

        // Create a gateway connection
        try (Gateway gateway = builder.connect()) {

            // Obtain a smart contract deployed on the network.
            Network network = gateway.getNetwork("mychannel");
            Contract contract = network.getContract("fabcar");

            // Submit transactions that store state to the ledger.
            byte[] createCarResult = contract.createTransaction("createCar")
                    .submit("CAR10", "VW", "Polo", "Grey", "Mary");
            System.out.println(new String(createCarResult, StandardCharsets.UTF_8));

            // Evaluate transactions that query state from the ledger.
            byte[] queryAllCarsResult = contract.evaluateTransaction("queryAllCars");
            System.out.println(new String(queryAllCarsResult, StandardCharsets.UTF_8));

        } catch (ContractException | TimeoutException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}

API documentation

Full Javadoc documentation is published for each of the following versions:

Maven

Add the following dependency to your project's pom.xml file:

<dependency>
  <groupId>org.hyperledger.fabric</groupId>
  <artifactId>fabric-gateway-java</artifactId>
  <version>2.2.0</version>
</dependency>

Gradle

Add the following dependency to your project's build.gradle file:

implementation 'org.hyperledger.fabric:fabric-gateway-java:2.2.0'

Compatibility

The following table shows versions of Fabric, Java and other dependencies that are explicitly tested and that are supported for use with version 2.2 of the Fabric Gateway SDK. Refer to the appropriate GitHub branch for compatibility of other release versions.

Tested Supported
Fabric 2.2 2.2
Java 8, 11 8+
Platform Ubuntu 20.04

Client applications running on POWER architecture

To run Java SDK clients on IBM POWER systems (e.g. zLinux), use Java 11 and set the SSL provider to ‘JDK’ by either supplying the -D command line option:

-Dorg.hyperledger.fabric.sdk.connections.ssl.sslProvider=JDK

or with the environment variable set as follows:

ORG_HYPERLEDGER_FABRIC_SDK_CONNECTIONS_SSL_SSLPROVIDER=JDK

Building and testing

git clone https://github.com/hyperledger/fabric-gateway-java.git
cd fabric-gateway-java
mvn install

The mvn install command will download the dependencies and run all the unit tests and scenario tests. It will also generate all the crypto material required by these tests.

Docker is required to run the scenario tests.

Unit tests

All classes and methods have a high coverage (~90%) of unit tests. These are written using the JUnit, AssertJ and Mockito frameworks.

Scenario tests

Scenario tests are written using the Cucumber BDD framework.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].