https://github.com/hyperledger/fabric-chaincode-java
Hyperledger Fabric Contract and Chaincode implementation for Java
https://github.com/hyperledger/fabric-chaincode-java
hacktoberfest hyperledger hyperledger-fabric java smart-contracts
Last synced: 8 months ago
JSON representation
Hyperledger Fabric Contract and Chaincode implementation for Java
- Host: GitHub
- URL: https://github.com/hyperledger/fabric-chaincode-java
- Owner: hyperledger
- License: apache-2.0
- Created: 2017-08-01T19:13:14.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-04-04T14:15:53.000Z (10 months ago)
- Last Synced: 2025-05-08T10:53:08.975Z (9 months ago)
- Topics: hacktoberfest, hyperledger, hyperledger-fabric, java, smart-contracts
- Language: Java
- Homepage: https://hyperledger.github.io/fabric-chaincode-java/
- Size: 5.46 MB
- Stars: 310
- Watchers: 26
- Forks: 207
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Hyperledger Fabric Chaincode Java
[](https://dev.azure.com/Hyperledger/Fabric-Chaincode-Java/_build/latest?definitionId=39&branchName=main)
[](https://maven-badges.herokuapp.com/maven-central/org.hyperledger.fabric-chaincode-java/fabric-chaincode-shim)
[](https://discordapp.com/channels/905194001349627914/943090527920877598)
This is a Java based implementation of Hyperledger Fabric chaincode shim APIs, which enables development of smart contracts using the Java language.
This project creates `fabric-chaincode-shim` jar
files for developers' consumption and the `hyperledger/fabric-javaenv` docker image
to run Java chaincode.
## Getting Started
Application developers interested in developing Java smart contracts for Hyperledger Fabric should read the [JavaDoc](https://hyperledger.github.io/fabric-chaincode-java/) which includes download information, and links to documentation and samples.
## Project structure
### fabric-chaincode-shim
Contains the java shim classes that define Java chaincode API and way to communicate with Fabric peers.
### fabric-chaincode-docker
Contains instructions to build the `hyperledger/fabric-javaenv` docker image.
### fabric-chaincode-integration-test
Contains higher level tests for Java chaincode.
> **Note:** in the future these should be replaced with a separate suite of [Cucumber](https://cucumber.io) tests which run against all chaincode implementations.
### examples
The following technical examples are in this repository. Please see the tutorials in the [documentation](https://hyperledger-fabric.readthedocs.io/en/latest/tutorials.html)
- **fabric-contract-example-gradle** - Contains an example Java contract built using gradle
- **fabric-contract-example-maven** - Contains an example Java contract built using maven
- **fabric-contract-example-gradle-kotlin** - Contains an example Kotlin contract build using gradle (Kotlin gradle files)
- **fabric-chaincode-example-sacc** - Contains an example java chaincode gradle project that includes sample chaincode and basic gradle build instructions.
- **fabric-chaincode-example-sbe** - Contains an example java chaincode gradle project that includes state based endorsement
## 'dev' main branch builds
These 'dev' drivers are built from the main branch only, and have a version format including the date for example `2.3.1.dev.20210303`.
They are published to Artifactory. These can be accessed via the repository at
```
maven {
url "https://hyperledger.jfrog.io/hyperledger/fabric-maven"
}
```
They can be accessed in a build file like this
```
dependencies {
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.3.1.dev.+'
}
```
## Building and testing
Make sure you have the following prereqs installed:
- [Docker](https://www.docker.com/get-docker)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [JDK 11](https://adoptium.net/)
> **Note:** Java can be installed using [sdkman](https://sdkman.io/).
Clone the repository if you haven't already.
```
git clone https://github.com/hyperledger/fabric-chaincode-java.git
```
Build java shim jars (proto and shim jars) and install them to local maven repository.
```
cd fabric-chaincode-java
./gradlew clean build install
```
> **Note:** `./gradlew clean build classes` can be used instead to reduce the binaries that are built. This should be sufficient for using the local repository.
Build javaenv docker image, to have it locally.
```
./gradlew buildImage
```
## Compatibility
For details on what Java runtime and versions of Hyperledger Fabric can be used please see the [compatibility document](COMPATIBILITY.md).
---
[](http://creativecommons.org/licenses/by/4.0/)
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/)