Practice of Lesson 1-3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Practices for Lesson 1:

Introduction to Hyperledger
Fabric
Practices for Lesson 1

Overview
In these practices, you will learn to create AWS Managed Blockchain Network, VPC Endpoint,
Fabric Client Instance and setting of the IAM permissions.

Use Case
• Blockchain technology accelerates the Mortgage Lending Process. In this course we
consider one such Mortgage Loan Process i.e, Gold Loan. The Implementation is based
on Hyperledger Fabric which is a distributed ledger framework.
• The Implementation handles Gold Loan Transactions between Service Provider and the
Customers.
• The Hyperledger Fabric Ledger keeps track of the transactions made between the
Service Provider and the Customers.
• The Chaincode implementations in this Course includes Invoking Gold Loan Application,
Business Logic for Quality Test and Customer getting the Application Status.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

2 Practices for Lesson 1: Introduction to Hyperledger Fabric


Practice 1-3: Installing Hyperledger Fabric CLI tool and Setup the
Hyperledger Fabric CA Client

Overview
In this practice, you will learn to install Hyperledger Fabric CLI tool and set up the Hyperledger
Fabric CA client

Assumption
You should have completed the Practice 1-2

Tasks:
1. Connect to the Hyperledger Fabric EC2 Instance using Putty CLI tool.

a. Install putty tool on local system.


b. Open Puttygen and click on Load to save the download blockchain.pem file as
Private Key in .PPK format with the same name.

c. After loading the key in the generator, click Save private key. It downloads the
private key in .ppk format.
d. Navigate to EC2 console and select the Instance you have created, scroll down and
copy the IPV4 Public IP address as shown below.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practices for Lesson 1: Introduction to Hyperledger Fabric 3


e. Open Putty enter the Host IP address of the Instance copied in the previous step as
shown below.

f. Further, expand SSH and select auth under the category of Putty configuration.
Provide the path of Private key and click Open as shown below.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

4 Practices for Lesson 1: Introduction to Hyperledger Fabric


g. Provide the Host name as ec2-user when the terminal opens.

2. Install the required Hyperledger Fabric client packages into EC2 instance
a. Run the commands to update the Linux packages and install jq (command-line
JSON processor) as shown below.
$sudo yum update -y
$sudo yum install jq -y

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practices for Lesson 1: Introduction to Hyperledger Fabric 5


b. Run the following commands to install Telnet.
$sudo yum install -y telnet

c. Run the following commands to install Emacs as shown below.


$sudo yum -y install emacs

d. Install Docker in Linux Instance. Start the Docker by running the below commands
and configure the user for Docker.
Note: To run the Docker command without sudo, logout and login again into the
instance.
$sudo yum install -y docker
$sudo service docker start
$sudo usermod -a -G docker ec2-user

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

6 Practices for Lesson 1: Introduction to Hyperledger Fabric


e. Run the below command to install Docker Compose and Libtool
$sudo curl -L \
https://github.com/docker/compose/releases/download/1.20.0/doc
ker-compose-`uname \
-s`-`uname -m` -o /usr/local/bin/docker-compose

$sudo chmod a+x /usr/local/bin/docker-compose


$sudo yum install libtool -y

f. Further, install Golang by running the below commands


$wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
$tar -xzf go1.14.4.linux-amd64.tar.gz
$sudo mv go /usr/local
$sudo yum install libtool-ltdl-devel -y
$sudo yum install git -y

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practices for Lesson 1: Introduction to Hyperledger Fabric 7


3. Set up the variables such as GOROOT and GOPATH in bash profile
a. Navigate to AWS managed blockchain member console. Copy the
CASERVICEENDPOINT and ORDERER in notepad for further use.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

8 Practices for Lesson 1: Introduction to Hyperledger Fabric


b. Edit the bash profile by using vi editor. Run the command vi ~/.bash_profile,
replace the code present in the bash profile.
c. Copy the below code and paste it in the bash profile.
# .bash_profile

# Get the aliases and functions


if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs


PATH=$PATH:$HOME/.local/bin:$HOME/bin

# GOROOT is the location where Go package is installed on your


system
export GOROOT=/usr/local/go

# GOPATH is the location of your work directory


export GOPATH=$HOME/go

# CASERVICEENDPOINT is the endpoint to reach your member's CA

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practices for Lesson 1: Introduction to Hyperledger Fabric 9


# for example ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n-
MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-
1.amazonaws.com:30002
export CASERVICEENDPOINT=MyMemberCaEndpoint

# ORDERER is the endpoint to reach your network's orderer


# for example orderer.n-
MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.amazonaws.com:300
01
export ORDERER=MyNetworkOrdererEndpoint

# Update PATH so that you can access the go binary system wide
export PATH=$GOROOT/bin:$PATH
export PATH=$PATH:/home/ec2-
user/go/src/github.com/hyperledger/fabric-ca/bin
d. In bash profile, edit the CASERVICEENDPOINT and ORDERER that is saved in the
previous step.

e. After the changes is applied, save the file and source the bash profile by running the
below command
$source ~/.bash_profile
4. Set up the AWS CLI and verify the connection to the Hyperledger Fabric CA
a. Set up the AWS command line interface and provide the region by running the below
command.
$aws configure

b. Verify the connection to the Hyperledger Fabric CA by running the below command

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

10 Practices for Lesson 1: Introduction to Hyperledger Fabric


$aws managedblockchain get-member --network-id <ID> --member-
id <ID>

c. Run the below command to verify the endpoint resolves.


$curl https://$CASERVICEENDPOINT/cainfo -k

d. Verify the connection to the Fabric CA using telnet by running the below command
$telnet <CAENDPOINT> <CAPORT>

5. Configure the Hyperledger Fabric CA Client


a. Run the below command to install and build the client version
$mkdir -p /home/ec2-user/go/src/github.com/hyperledger/fabric-
ca
$cd /home/ec2-user/go/src/github.com/hyperledger/fabric-ca
$ wget https://github.com/hyperledger/fabric-
ca/releases/download/v1.4.7/hyperledger-fabric-ca-linux-amd64-
1.4.7.tar.gz
$tar -xzf hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practices for Lesson 1: Introduction to Hyperledger Fabric 11


b. Verify the Hyperledger fabric CA is installed successfully

6. Logout from the AWS console and close the putty terminal.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

12 Practices for Lesson 1: Introduction to Hyperledger Fabric

You might also like