*****At this point you should have a Linux VM fully setup and you are now ready to download the docker images for the various components of your Blockchain network.****

Clone the Hyperledger Fabric v1 Images

You can download the images here and this will show you how to call chaincode directly at the command line. Later on we will use Composer to spin up docker images and write to the chain by deploying a business network archive.

Architecture Overview
All Hyperledger projects follow a design philosophy that includes a modular extensible
approach, interoperability, an emphasis on highly secure solutions, a token-agnostic
approach with no native cryptocurrency, and the development of a rich and easy-touse
Application Programming Interface (API). The Hyperledger Architecture WG has
distinguished the following business blockchain components:
• Consensus Layer – Responsible for generating an agreement on the order and
confirming the correctness of the set of transactions that constitute a block.
• Smart Contract Layer – Responsible for processing transaction requests and
determining if transactions are valid by executing business logic.
• Communication Layer – Responsible for peer-to-peer message transport between
the nodes that participate in a shared ledger instance.
• Data Store Abstraction – Allows different data-stores to be used by other modules.
• Crypto Abstraction – Allows different crypto algorithms or modules to be swapped
out without affecting other modules.
• Identity Services – Enables the establishment of a root of trust during setup of a
blockchain instance, the enrollment and registration of identities or system entities
during network operation, and the management of changes like drops, adds, and
revocations. Also, provides authentication and authorization.
• Policy Services – Responsible for policy management of various policies specified
in the system, such as the endorsement policy, consensus policy, or group
management policy. It interfaces and depends on other modules to enforce the
various policies.
• APIs – Enables clients and applications to interface to blockchains.
• Interoperation – Supports the interoperation between different blockchain instances.

To Setup and use Couch DB for richer queries follow the tutorial here.

To clean and bring down the network use

./network_setup.sh down
sudo docker ps

you shouldn’t see any containers running.

To stop individual various containers use

sudo docker stop <name>
sudo docker rm <name>

To learn about the Hyperledger Fabric API visit http://jimthematrix.github.io/ This is a great resource for learning about the intricacies of the network and the different certificates needed for trusted transactions.

Below is the second part the Application Layer, Fabric Composer.

The Application Layer

You have configured and setup a VM, you have your docker containers running, your Hyperledger Fabric V1.0 blockchain infrastructure is live; now you want to model, build and deploy a business application on this network. This article will show you exactly how to wire up the application layer and the infrastructure layer.

You can run the network locally using npm or docker

npm install -g composer-playground

docker run -d -p 8080:8080 hyperledger/composer-playground

Once you have configure your business network you can export it in a BNA (business network archive file).

The Business Network

Permissioned blockchain technology applications built for the enterprise and commercial applications need an abstraction layer. This is provided by Fabric Composer; a toolset and application framework that enables you to quickly model and deploy applications to Fabric infrastructure. It is a framework that enables you to reason about the Participants, the Assets, and the Transaction logic that drive state changes on your distributed ledger. This business logic and processes are what will drive the distributed state changes to the peers on your network.

Hyperledger Fabric Composer

Fabric Composer is an open-source project and part of the Hyperledger Foundation.

First, ssh into the same VM you setup.

ssh -i ./yourkeyname.pem ubuntu@yoururlname

Installing Fabric Composer Dev Tools

You should have the majority of these tools installed in your configured VM but this script will make sure everything is correct versions and you haven’t missed anything.

The composer-cli contains all the command line operations for developing business networks.

To install generator-hyperledger-composer run the following command:

npm install -g generator-hyperledger-composer

The generator-hyperledger-composer is a Yeoman plugin that creates bespoke applications for your business network.

To install composer-rest-server run the following command:

npm install -g composer-rest-server

The composer-rest-server uses the Hyperledger Composer LoopBack Connector to connect to a business network, extract the models and then present a page containing the REST APIs that have been generated for the model.

To install Yeoman run the following command:

npm install -g yo

Yeoman is a tool for generating applications. When combined with the generator-hyperledger-composer component, it can interpret business networks and generate applications based on them.

If you use VSCode, install the Hyperledger Composer VSCode plugin from the VSCode marketplace. There is also a plugin for Atom as well.

**********An ID Card contains an Identity for a single Participant within a deployed business network. ************

You have defined a Participant in your business network (modeled, but also actually created a record of one) given the participant an ID (id, name email) and now; the above. The ID Card contains an Identity for that single Participant within the deployed business network.

It is like your auth method. You create the participant on the network and then you can go and create an ID that lets you sign as as that participant. Then create another participant, maybe same type, different type; then create another ID for that one.

*** Command Line – Create Profile ***

Issue from the fabric-tools directory ./createComposerProfile.sh

This script will create an PeerAmin Profile for you.

Connection profiles are a bit confusing and can be frustrating to setup, but, this is an integral part to being able to build and deploy your business network.

There are two folders on your machine:

cd ~/.composer-credentials

and

cd ~/.composer-connection-profiles

When you run Composer locally using Docker containers the Profiles you create will be stored there.

You can find you and PeerAdmin Profile pub, priv keys in the composer-credentials directory.

You may run into a problem command if your setup is still sudoed out, so you will need to check and see using

ls -la /home/ubuntu/.composer-credentials

Then if it is run

sudo chown -R ubuntu /home/ubuntu/.composer-credentials

Network Teardown

Also, here are some more scripts more to stop and tear down the infrastructure layer.

./stopFabric.sh

At this point you can go should be ready to get dialed in and ready to model out and wire up a business network. Grab some coffee, a nice glass of water, new piece of gum; you’re just about to get going. This next part we are going to connect a Sample Business Network to your Hyperledger Fabric V1 Blockchain.

To start over do this

./teardownFabric.sh

Or continue On… to connect a Sample Business Network to your Hyperledger Fabric V1 Blockchain.

Building Your Business Network

This section isn’t mandatory but if you want to use the playground editor this is some background on how to to access it in the browser Or you can skip this and use vim.

Make sure fabric composer is running, your security groups have inbounds and outbounds open and go to your amazon web services url:

Model your Business Network using the Hyperledger Composer Playground. A Hyperledger Composer Business Network Definition is composed of a set of model files and a set of scripts. This can be run in the browser or locally using a docker container.

Modeling a Business Network consist of :

Participants – Members of the Business Network

Assets –

Transactions – State change mechanism of the Network

You also are able to use:

Concepts

enum

abstract

Lastly, the Business Network can define:

Events – Defined indicators that can be subscribed to by external systems

Access Control – Permissions for state changes

You can use Javascript to define the transactional logic that you would like to use in your applications. We are just going to use a Sample Business Network, this can be edited and redeployed to update the Blockchain.

Clone a sample network using this repo:

git clone https://github.com/hyperledger/composer-sample-networks.git

cd packages
cd basic-sample-network
npm install

You should get something like this:

Creating Business Network Archive

Looking for package.json of Business Network Definition
Input directory: /home/ubuntu/my-network

Written Business Network Definition Archive file to
Output file: ./dist/my-network.bna

Command succeeded

Deploying Your Business Network To Your Blockchain Infrastructure

Once you have your Sample Business Network you are going to want to create a BNA file. A BNA is the Business Network Archive, it is a file that describes your network configuration and application and can be deployed the the infrastructure you have setup. To deploy your network use:

Setting up our REST Server

Hyperledger Fabric v1.0 provides basic API using Protocol Buffers over gRPC for applications to interact with the blockchain network. Composer enables you to create REST server and communicate with the Blockchain network using JSON. This part is important and you should have an understanding of it before starting on modeling out your business network / application. Composer enables you to create a REST server that is dynamically generated based on the business network participants and asset you design. You can configure your network and launch a REST Api that can be called from other applications.

composer-rest-server

Wiring It All Up

Once your business Network is deployed to your infrastructure you should be able to verify it using the top right, your connection profile is connected. You are now ready to send transactions to the blockchain directly from the composer interface or by calling your REST server from a client.

If you are running into any trouble feel free to reach out at dominic@dapps.ai

“We need to make our examples/scripts work with production-level
artifacts. The fabric-testenv-orderer image is not an artifact targeted
for production. This abundance of options leads to user confusion…
This changeset removes all references to the fabric-testenv-orderer
Docker image.”

npm ERR! hashtable@2.0.2 install: `node-gyp configure build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the hashtable@2.0.2 install script ‘node-gyp configure build’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hashtable package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hashtable
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls hashtable
npm ERR! There is likely additional logging output above.

Is it possible to run orderer without using docker at all ? Do you know of any documentations available for the same which lists out all pre-requisities. Moreover, I read some very bad reviews about running docker on AWS or in general in production https://thehftguy.com/2016/11/01/docker-in-production-an-history-of-failure/ and there are few more. I have been working on an idea based on fabric blockchain for the past couple of months and now want to take it live. I am bit worried after reading all such blogs. I was wondering if it is possible to setup and run whole fabric network without using docker at all ?

I am new to this and hence i need some help. Using Cloud Formation, i created a Hyper ledger template and i on successful creation of stack, i could go to private IP and see the Hyper Ledger Explorer UI template. what do i do next. How to 1. Deploy this using EC2? 2. how to connect the smart contract to this template 3. how to make transactions between peers? Thanks in advance for the help