Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

fabric-sdk-java

> 编程语言
Open source

Hyperledger Fabric SDK for Java Note: This API is deprecated. When developing applications for Hyperledger Fabric v2.4 and later, you shoul…

1.1K stars0 likes1 views
WebsiteGitHub

About

Hyperledger Fabric SDK for Java Note: This API is deprecated. When developing applications for Hyperledger Fabric v2.4 and later, you shoul…

Hyperledger Fabric SDK for Java

Note: This API is deprecated. When developing applications for Hyperledger Fabric v2.4 and later, you should use the Fabric Gateway client API. When developing applications for earlier Fabric versions, you are strongly encouraged to use the high-level API detailed below.

This project provides a low-level API for interacting with Hyperledger Fabric blockchain networks, and is used by the high-level Hyperledger Fabric Gateway SDK for Java:

  • Documentation: https://hyperledger.github.io/fabric-gateway-java/
  • GitHub repository: https://github.com/hyperledger/fabric-gateway-java/

The information below is intended for contributors to this repository.


Introduction for contributors

The SDK provides a layer of abstraction on top of the wire-level protobuf based communication protocol used by client applications to interact with a Hyperledger Fabric blockchain network. It allows Java applications to manage the lifecycle of Hyperledger channels and user chaincode. The SDK also provides a means to execute user chaincode, query blocks and transactions on the channel, and monitor events on the channel.

The SDK acts on behalf of a particular User which is defined by the embedding application through the implementation of the SDK's User interface.

Note, the SDK does not provide a means of persistence for the application defined channels and user artifacts on the client. This is left for the embedding application to best manage. Channels may be serialized via Java serialization in the context of a client. Channels deserialized are not in an initialized state. Applications need to handle migration of serialized files between versions.

The SDK also provides a client for Hyperledger's certificate authority. The SDK is however not dependent on this particular implementation of a certificate authority. Other Certificate authority's maybe used by implementing the SDK's Enrollment interface.

This provides a summary of steps required to get you started with building and using the Java SDK. Please note that this is not the API documentation or a tutorial for the SDK, this will only help you familiarize to get started with the SDK if you are new in this domain.

Release notes

Release Notes Summary
2.1 v2.1 release notes Minor update
2.0 v2.0 release notes

New lifecycle chaincode management

Connection config handlers

Application setting executor service

Queued block listener

| |1.4 | None | Minor updates no Fabric changes| |1.3 | v1.3 release notes|

Java chaincode support

Query chaincode collection configuration

Identity Mixer transaction unlinkabilty support

| |1.2 | v1.2 release notes|

Private data collection support

Service discovery

Fabric CA certificate API | |1.1 | v1.1 release notes|

Channel service events

FilterBlocks

JCA/JCE compliance

Chaincode events

Node chaincode

|

Checkout SDK from Github

bash
git clone https://github.com/hyperledger/fabric-sdk-java.git
cd fabric-sdk-java/

Production Java applications

For Java applications use the latest released version of the SDK v1.4.x releases:

     
     
         org.hyperledger.fabric-sdk-java
         fabric-sdk-java
         1.4.7
     

For v2.0 work in progress use 2.0.0-SNAPSHOT builds

Work in progress 2.0.0 SNAPSHOT builds can be used by adding the following to your application's pom.xml

    
        
            snapshots-repo
            https://oss.sonatype.org/content/repositories/snapshots
            
                false
            
            
                true
            
        
    

        
        
            org.hyperledger.fabric-sdk-java
            fabric-sdk-java
            2.0.0-SNAPSHOT
        

Java and Node Chaincode environment

You may also need to on your v2.1 Fabric network docker deployment explicitly pull the Java and Node chaincode environments for now.

docker pull hyperledger-fabric.jfrog.io/fabric-nodeenv:amd64-2.1.0-stable&&docker tag hyperledger-fabric.jfrog.io/fabric-nodeenv:amd64-2.1.0-stable hyperledger/fabric-nodeenv:amd64-latest&&docker tag hyperledger-fabric.jfrog.io/fabric-nodeenv:amd64-2.1.0-stable hyperledger/fabric-nodeenv

docker pull hyperledger-fabric.jfrog.io/fabric-javaenv:amd64-2.1.0-stable&&docker tag hyperledger-fabric.jfrog.io/fabric-javaenv:amd64-2.1.0-stable hyperledger/fabric-javaenv:amd64-latest&&docker tag hyperledger-fabric.jfrog.io/fabric-javaenv:amd64-2.1.0-stable hyperledger/fabric-javaenv

Known limitations and restrictions

  • TCerts are not supported: JIRA FAB-1401

SDK dependencies

SDK depends on few third party libraries that must be included in your classpath when using the JAR file. To get a list of dependencies, refer to pom.xml file or run mvn dependency:tree or mvn dependency:list. Alternatively, mvn dependency:analyze-report will produce a report in HTML format in target directory listing all the dependencies in a more readable format.

To build this project, the following dependencies must be met

  • JDK 1.8 or above
  • Apache Maven 3.5.0

To run the integration tests Fabric and Fabric CA is needed which require

  • Docker 18.03
  • Docker compose 1.21.2

Using the SDK

Setting Up Eclipse

If you want to get started using the Fabric Java SDK with Eclipse, refer to the instructions at: ./docs/EclipseSetup.md

Compiling

Once your JAVA_HOME points to your installation of JDK 1.8 (or above) and JAVA_HOME/bin and Apache maven are in your PATH, issue the following command to build the jar file:

mvn install

or

mvn install -DskipTests if you don't want to run the unit tests

Running the unit tests

To run the unit tests, please use mvn install which will run the unit tests and build the jar file.

Many unit tests will test failure condition's resulting in exceptions and stack traces being displayed. This is not an indication of failure!

[INFO] BUILD SUCCESS At the end is usually a very reliable indication that all tests have passed successfully!

Running the integration tests

The script below both sets up the test environment and runs the tests.

bash
./scripts/run-integration-tests.sh

End to end test scenario

Following the below integration tests/example code shows almost all that the SDK can do. To learn the SDK you must have some understanding first of Fabric Hyperledger. Then it's best to study the integrations tests and better yet work with them in a debugger to follow the code ( a live demo ). Start first with End2endIT.java and then End2endAndBackAgainIT.java samples before exploring the other samples. Then once you understand them you can cut and paste from there to your own application. ( the code is done for you! )

Note These samples are for testing, validating your environment and showing how to use the APIs. Most show a simple balance transfer. They are not meant to represent best practices in design or use of chaincode or the use of the SDK.

Integration Test Summary and notes
End2endLifecycleIT.java

New lifecycle chaincode management APIs (v2.0) :fire: Fabric read the docs: Chaincode for Operators

| |End2endIT.java|

Register and enroll users with Fabric certificate authority.

Constructing channel first time.

Installing chaincode. DEPRECATED see v2.0 release notes!

Instantiating chaincode. DEPRECATED see v2.0 release notes!

Executing chaincode.

Querying channel for block information.

Chaincode event listener

Traversing block for information.

Prerequisite for all other testcases.

| |End2endAndBackAgainIT.java|

Recreate channel.

Update chaincode.

Checking installed and instantiated chaincode. DEPRECATED see v2.0 release notes!

| |End2endNodeIT.java|

Shows running End2endIT.java but with Node chaincode.

Note subclasses En2endIT class.

| |End2endJavaIT.java|

Shows running End2endIT.java but with Java chaincode.

Note subclasses En2endIT class.

| |End2endIdemixIT.java|

Shows running End2endIT.java but with Idemix credentials.

Note subclasses En2endIT class.

| |NetworkConfigIT.java|

Shows recreating channel with common connection profile.

User defined handlers for creating Peers and Orderers (v2.0) :fire: .

| |PrivateDataIT.java|

Shows instantiating and installing chaincode that defines private data.

Information on Fabric private data can be found read the docs.

| |UpdateChannelIT.java|

Shows updating channel configuration.

Details on channel configurations can be found on read the docs Channel Configuration

Queued block listener (v2.0) :fire:

| |ServiceDiscoveryIT.java|

Shows service discovery.

Details on service discovery can be found on read the docs Service Discovery

Note: requires adding entries in host file to remap docker fabric Peer and Orderers address to localhost

|

End to end test environment

The test defines one Fabric orderer and two organizations (peerOrg1, peerOrg2), each of which has 2 peers, one fabric-ca service.

Certificates and other cryptography artifacts

Fabric requires that each organization has private keys and certificates for use in signing and verifying messages going to and from clients, peers and orderers. Each organization groups these artifacts in an MSP (Membership Service Provider) with a corresponding unique MSPID .

Furthermore, each organization is assumed to generate these artifacts independently. The fabric-ca project is an example of such a certificate generation service. Fabric also provides the cryptogen tool to a

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javablockchaindistributed-ledgerfabrichyperledger

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言