Subodh Kamble Roll 20 MSc Computer Science Part 2
Practical 2: Create and deploy a block chain network using Hyperledger Fabric SDK for Java.
Prerequisites:
1. Java Development Kit (JDK) 11 or later: Install JDK 11 or a later version
on your system. You can download it from
[Link]
2. Maven 3.8.1 or later: Install Maven 3.8.1 or a later version on your
system. You can download it from
[Link]
3. Docker Desktop 20.10.14 or later (if using Dockized environment):
Install Docker Desktop 20.10.14 or a later version if you want to use the
Dockerized environment
Installing Hyperledger Fabric SDK for Java:
• Download the Hyperledger Fabric SDK for Java: Go to the Hyperledger
Fabric releases page ([Link]
and download the latest binary distribution for your operating system.
• Extract the SDK: Extract the downloaded binary archive to a location of
your choice. For example, you can extract it to a directory named fabric-
sdk-java in your home directory.
• Set environment variables: Add the following environment variables to
your system's environment variables:
Subodh Kamble Roll 20 MSc Computer Science Part 2
export FABRIC_HOME=/path/to/fabric-sdk-java
export JAVA_HOME=/path/to/jdk11.0.17
Replace the paths with the actual locations of your fabric-sdk-java and
jdk11.0.17 directories.
• Setting up the Fabric Test Network:
• Clone the Fabric Samples repository: Open a terminal window and
navigate to a directory where you want to store the Fabric Samples
repository. Then, clone the repository using the following command:
git clone [Link]
• Go to the test-network directory: Navigate into the test-network
directory within the cloned repository:
cd fabric-samples/test-network
Launch the Fabric test network: Use the following command to launch the
Fabric test network:
./[Link] up
Subodh Kamble Roll 20 MSc Computer Science Part 2
This command will start a Hyperledger Fabric test network with two peers, an
ordering service, and three certificate authorities.
./[Link] down
This command will stop Hyperledger Fabric test network with two peers.
Interacting with the Fabric Test Network:
Install the Fabric CLI tools: Download the appropriate Fabric CLI binaries for
your operating system from the Hyperledger Fabric releases page
([Link] Extract the downloaded
archive and add the following path to your environment variables:
!Optional:
export FABRIC_BIN=/path/to/fabric-binaries
Subodh Kamble Roll 20 MSc Computer Science Part 2
Replace the path with the actual location of your extracted Fabric CLI binaries.
Install the Fabric Java SDK tools: Install the Fabric Java SDK tools using Maven:
mvn install
This command will install the necessary tools for interacting with the Fabric
test network from Java applications.
./[Link] up createChannel
Subodh Kamble Roll 20 MSc Computer Science Part 2
Package the smart contract Java:
Cd /fabric-samples/asset-transfer-basic/chaincode-java
Subodh Kamble Roll 20 MSc Computer Science Part 2
docker build .
./[Link] up createChannel -c mychannel –ca
Subodh Kamble Roll 20 MSc Computer Science Part 2
Deploy the smart contract Java¶
./[Link] deployCC -ccn basic -ccp ../asset-transfer-
basic/chaincode-java/ -ccl java
Subodh Kamble Roll 20 MSc Computer Science Part 2