Set up and initialize the channel, install and instantiate chaincode, and perform invoke and query on your blockchain network

Summary

In a blockchain solution, the network works as a back end with an application front end to communicate with the network using an SDK. To set up the communication between the front and back ends, the Hyperledger Fabric community provides a number of SDKs for a variety of programming languages, including Node.js, Java, and Python. Read on to learn how to create, deploy, and work with the network using Hyperledger Fabric SDK Java 1.0.

Description

Have you ever tried to build a Hyperledger Fabric Java blockchain app? Did you run into issues or couldn’t find the proper documentation? If that sounds familiar, this developer code pattern will help you get the process started.

Blockchain is a shared, immutable ledger for recording the history of transactions. Hyperledger is a collaborative open source effort created to advance cross-industry blockchain technologies. Hyperledger Fabric is a blockchain framework implementation and one of the Hyperledger projects hosted by The Linux Foundation. The Hyperledger Fabric platform provides solutions for a distributed ledger underpinned by a modular architecture delivering high degrees of confidentiality, resiliency, flexibility, and scalability.

In a blockchain solution, the blockchain network works as a back end with an application front end to communicate with the network using an SDK. To set up the communication between the front and back ends in Java, Hyperledger Fabric provides Hyperledger Fabric SDK Java SDK. It provides a means to execute user chaincode, query blocks, and transactions on the channel, and monitor events on that channel. This code pattern explains how to create, deploy, and work with the network using Hyperledger Fabric SDK Java 1.0.

In this pattern, the blockchain network is built using Docker Compose and will provision a Hyperledger Fabric 1.1 network consisting of two organizations, each maintaining two peer nodes, two certificate authorities for each peer, and a solo ordering service. This pattern demonstrates creating and initializing the channel, installing and instantiating chain code, and performing invoke and query on your blockchain network.

Flow

Generate the artifacts using cryptogen and configtx for peers and channel in network. These are already generated and provided in the code repository to use as-is.

Build the network using Docker Compose and the generated artifacts.

Use Hyperledger Fabric Java SDK APIs to work with and manage the network:

Create and initialize the channel.

Install and instantiate the chaincode.

Perform invoke and query to test the network.

Instructions

To put this code pattern to use, see the details on how to get started running and using this application in the README.