0% found this document useful (0 votes)
136 views

Practical 2 Create and Deploy A Block Chain Network Using Hy

This document provides instructions for setting up and deploying a Hyperledger Fabric blockchain network using the Hyperledger Fabric SDK for Java. It outlines prerequisites like installing Java and Docker, downloading and extracting the Fabric SDK, and setting environment variables. It then describes cloning the Fabric samples repository, launching the Fabric test network, installing Fabric CLI tools, packaging and deploying a smart contract written in Java.

Uploaded by

pooja Jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views

Practical 2 Create and Deploy A Block Chain Network Using Hy

This document provides instructions for setting up and deploying a Hyperledger Fabric blockchain network using the Hyperledger Fabric SDK for Java. It outlines prerequisites like installing Java and Docker, downloading and extracting the Fabric SDK, and setting environment variables. It then describes cloning the Fabric samples repository, launching the Fabric test network, installing Fabric CLI tools, packaging and deploying a smart contract written in Java.

Uploaded by

pooja Jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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
https://www.oracle.com/java/technologies/downloads/.

2. Maven 3.8.1 or later: Install Maven 3.8.1 or a later version on your


system. You can download it from
https://maven.apache.org/download.cgi.

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 (https://github.com/hyperledger/fabric/releases)
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 https://github.com/hyperledger/fabric-samples.git
• 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:
./network.sh 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.
./network.sh 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
(https://github.com/hyperledger/fabric/releases). 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.
./network.sh 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 .

./network.sh up createChannel -c mychannel –ca


Subodh Kamble Roll 20 MSc Computer Science Part 2

Deploy the smart contract Java¶

./network.sh deployCC -ccn basic -ccp ../asset-transfer-


basic/chaincode-java/ -ccl java
Subodh Kamble Roll 20 MSc Computer Science Part 2

You might also like