How to deploy a Hyperledger Composer .bna file and start the composer-rest-server
#1
In this tutorial, I will explain the process of deploying a .BNA file from Hyperledger Composer and then generate a composer-rest-server that will be accessible with a generated Angular app.

Pre-requisites
-Hyperledger Fabric & Composer Installed. Instructions
-.BNA file. Use your own or download here.

Step 1: Log into user created for installation
If you have followed our installation tutorial, log into the user called "playground" (or whichever user you used for installing Hyperledger Fabric).
[Image: attachment.php?aid=72]

Step 2: Navigate into the fabric-tools directory
Now navigate into the fabric-tools directory by running:
Code:
cd fabric-tools

Step 3: Create a Peer Admin Card
Before we begin installing our network, we will need an admin card. Let's create one by running:
Code:
./createPeerAdminCard.sh

Your terminal should now look like this:
[Image: attachment.php?aid=73]

Step 4: Download .bna file
If you do not already have a bna file in mind that you will be installing, you can download an example bna file for a car sales network, here. Then move the .bna file into the "fabric-tools" directory.

Step 5: Install the network
Now that we have our .bna file in the fabric-tools directory, let's install the network file.
Run:
Code:
composer network install -a car-sales-network.bna -c PeerAdmin@hlfv1

Your terminal should now look like:
[Image: attachment.php?aid=74]

**Note: If you are running into this error, "Error: Error trying install business network. Error: No valid responses from any peers", run this command:
Code:
./startFabric,sh

Then rerun:
Code:
composer network install -a car-sales-network.bna -c PeerAdmin@hlfv1
**

Step 6: Start the network
Now it's time to start the network. We will do this by running:
Code:
composer network start -c PeerAdmin@hlfv1 -n car-sales -V 0.0.2-deploy.1 -A admin -S adminpw

Your screen should now look like this:
[Image: attachment.php?aid=75]


!Important: The version number (after -V in the command above) must exactly match the version number in the package.json file. If the version numbers are a mismatch, you will receive this error, "Response from attempted peer comms was an error: Error 2: UNKNOWN; chaincode error (status: 500, message: cannot get package for chaincode (car-sales-network:0.0.1))". To grab the exact version number from a BNA file, unzip the BNA file (it is simply a ZIP package) and open the "package.json" file. The version number will be in this file. Copy it exactly.

Step 7: Import the created card
You will notice that the last step also created an admin card. Now it's time to import it.
Make sure they match as depicted below:
[Image: attachment.php?aid=76]

Run:
Code:
composer card import -f admin@car-sales.card

Step 8: Start the composer-rest-server
Everything is good to go! Let's start our REST server by running:
Code:
composer-rest-server -c admin@car-sales -n always -w true

Now you can view your REST server by navigating to: http://localhost:3000/explorer
Which will look like this:
[Image: attachment.php?aid=77]

Note: If you are running this on a public server, enabling user authentication is strongly recommended.


Attached Files Thumbnail(s)
                       
Reply
#2
Hi,

I created new folder called fabric-samples and downloaded the binaries and images as mentioned in the hyperledger docs http://hyperledger-fabric.readthedocs.io...stall.html (curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0).

But i dont see createPeerAdminCard.sh inside that? Can you please help me on this
Reply
#3
(07-25-2018, 07:57 AM)Sathish Kumar N S Wrote: Hi,

I created new folder called fabric-samples and downloaded the binaries and images as mentioned in the hyperledger docs http://hyperledger-fabric.readthedocs.io...stall.html (curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0).

But i dont see createPeerAdminCard.sh inside that? Can you please help me on this
Hyperledger Fabric 1.2 was just released a few weeks ago and Composer does not support it at this time of writing (it takes the dev team time to update the framework.)

You will need to run Fabric 1.1. It's possible that in Fabric 1.2 the ./createPeerAdminCard.sh was deprecated.
Reply
#4
(07-25-2018, 07:09 PM)admin Wrote:
(07-25-2018, 07:57 AM)Sathish Kumar N S Wrote: Hi,

I created new folder called fabric-samples and downloaded the binaries and images as mentioned in the hyperledger docs http://hyperledger-fabric.readthedocs.io...stall.html (curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0).

But i dont see createPeerAdminCard.sh inside that? Can you please help me on this
Hyperledger Fabric 1.2 was just released a few weeks ago and Composer does not support it at this time of writing (it takes the dev team time to update the framework.)

You will need to run Fabric 1.1. It's possible that in Fabric 1.2 the ./createPeerAdminCard.sh was deprecated.

Thanks. i have downloaded the fabric dev server as you mentioned.
Reply
#5
Hello,
I am getting this error,
While starting the network!


 $composer network start -c PeerAdmin@hlfv1 -n my-restaurant-network -V 0.0.2-deploy.3 -A admin -S adminpw
Starting business network my-restaurant-network at version 0.0.2-deploy.3

>
Processing these Network Admins:
    userName: admin

✖ Starting business network definition. This may take a minute...
Error: Error trying to start business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message:  is not a valid endorsement system chaincode)
Command failed

Can someone tell me where i am getting it wrong.
Reply
#6
Possibly something wrong with the BNA. MInd sharing so we can take a look at it?
Reply