Deploying and testing the business network for Hyperledger

For testing purposes, we will grant all participants full access to all of resources of the blockchain network:

  1. To achieve this, we will add the following lines to the permissions.acl file (without deleting any existing rules):
rule Default {
description: "Allow all participants access to all resources"
participant: "ANY"
operation: ALL
resource: "com.packtpublishing.businessnetwork.foodsafety.**"
action: ALLOW
}

With this rule defined, we will be able to deploy and test the ledger without any other extra permissions.

  1. After defining the network, we will generate a Business Network Archive (.bna file) and deploy it to the Hyperledger environment. Make sure that your environment is up and running before that. To create the .bna file, go into the root directory for the project and run the following command:
$ composer archive create -t dir -n .
Creating Business Network Archive
Looking for package.json of Business Network Definition
Input directory: /hands-on-iot-solutions-with-blockchain/ch7/food-safety-b10407
Found:
Description: Hands-on IoT solutions with Blockchain
Name: food-safety-b10407
Identifier: [email protected]
Written Business Network Definition Archive file to
Output file: [email protected]
Command succeeded
  1. If you haven't generated the PeerAdminCard yet, it's time to do so and import it with the createPeerAdminCard.sh script inside the directory where we have downloaded the fabric-dev servers:
$ ~/fabric-dev-servers/createPeerAdminCard.sh 
Development only script for Hyperledger Fabric control
Running 'createPeerAdminCard.sh'
FABRIC_VERSION is unset, assuming hlfv12
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)
Using composer-cli at v0.20.4
Successfully created business network card file to
Output file: /tmp/[email protected]
Command succeeded
Successfully imported business network card
Card file: /tmp/[email protected]
Card name: PeerAdmin@hlfv1
Command succeeded
The following Business Network Cards are available:
Connection Profile: hlfv1
┌─────────────────┬───────────┬──────────────────┐
Card Name UserId Business Network
├─────────────────┼───────────┼──────────────────┤
PeerAdmin@hlfv1 PeerAdmin
└─────────────────┴───────────┴──────────────────┘

Issue composer card list --card <Card Name> to get details a specific card
Command succeeded
Hyperledger Composer PeerAdmin card has been imported, host of fabric specified as 'localhost'
  1. When you have everything set up, install the .bna file into the environment and start the network by running the following commands:
$ composer network install --card PeerAdmin@hlfv1 --archiveFile [email protected] 
√ Installing business network. This may take a minute...
Successfully installed business network food-safety-b10407, version 0.0.1

Command succeeded
$ composer network start --networkName food-safety-b10407 --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin@hlfv1 --file networkadmin.card
Starting business network food-safety-b10407 at version 0.0.1

Processing these Network Admins:
userName: admin
√ Starting business network definition. This may take a minute...
Successfully created business network card:
Filename: networkadmin.card

Command succeeded
  1. Finally, import the network administrator card that was generated by the start process and ping the network to ensure it's running in the environment:
$ composer card import --file networkadmin.card
Successfully imported business network card
Card file: networkadmin.card
Card name: admin@food-safety-b10407

Command succeeded

$ composer network ping --card admin@food-safety-b10407

The connection to the network was successfully tested: food-safety-b10407
Business network version: 0.0.1
Composer runtime version: 0.20.4
participant: org.hyperledger.composer.system.NetworkAdmin#admin
identity: org.hyperledger.composer.system.Identity#f48a787ac40102cc7753336f8b15dd20fa3765e7b9049b2aeda4dcc3816d30c1

Command succeeded

At this point, we have created the first version of our network; generated the package for deployment (the .bna file); created the PeerAdminCard; installed the network to the Hyperledger Fabric environment; generated the NetworkAdminCard, which is responsible for managing the blockchain network; and started the network. 

With the Admin cards, we will send a ping command to ensure that the network is up and running. Now, let's improve our network.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.147.124