How to setup and build Hyperledger Fabric Blockchain Applications

This is an introduction to how to configure and launch the Hyperledger Fabric v1.0 permissioned blockchain network on an Ubuntu 16.04 Virtual Machine on AWS.

If you want to skip configuring the VM/images check out the IBM Bluemix Fabric managed service:

Below is the command line steps in addition to links to additional guides on configuring your network.

Creating your VM on AWS

The first thing you are going to do is go to AWS and create a new account:

Go to

Create your account and you will need to create a support request to increase the number of EC2 instances you can have.

Once your limit has increased you will launch a new EC2 Virtual Machine using the Launch Wizard.

Choose your Instance Type: c3.large

Go through the configuration screens and add storage to your VM 8/32/64 GB should work.

Once this has been done go to the Launch screen and generate a new key-pair for this Virtual Machine.

You will download the key pair and put it in some folder on your local machine.

Next the instance will launch and you will be able to see on your dashboard.

Copy the URL from your Virtual Machine

Open Git on your machine and go to the directory where you have downloaded the key to your Virtual Machine.

then ssh -i ./yourkeyname.pem ubuntu@yoururlname

once you have sshed in, you are now able to use the Virtual Machine.

Configuring your Virtual Machine

There are a number of packages that you are going to need to install and configure in your VM.

Install Git, Nodejs and GO

Digital Ocean Guide – Node.js

Installing GO and setting your GOPATH

sudo apt-get update

sudo apt-get install git

sudo apt-get install nodejs

sudo apt-get install npm

$ sudo tar -xvf go1.7.4.linux-amd64.tar.gz
$ sudo mv go /usr/local
cd ubuntu
mkdir yourgodirectoryname
export GOROOT=/usr/local/go 
export GOPATH=$HOME/yourgodirectoryname
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
sudo nano ~/.profile

Add the above three commands to the bttom of the /.profile file

Install Docker 1.12 and Docker-Compose 1.18

Digital Ocean Guide

sudo apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-add-repository 'deb ubuntu-xenial main'
sudo apt-get update

sudo apt-get install -y docker-engine


sudo curl -o /usr/local/bin/docker-compose -L "$(uname -s)-$(uname -m)"
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v

*****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

This is the Fabric Getting Started Guide and here is the end-to-end guide on Github

cd ubuntu
cd yourgodirectoryname
mkdir src
cd src
mkdir hyperledger
cd hyperledger
git clone
sudo apt install libtool libltdl-dev

Download the Docker Images for Fabric v1.0

cd fabric
make release-all
make docker
docker images

You should see your docker images    (this is for x86_64-1.0.0-alpha2)

REPOSITORY TAG IMAGE ID CREATED SIZE latest 73c7549744f3 6 days ago 176MB
hyperledger/fabric-couchdb latest 3d89ac4895f9 12 days ago 1.51GB
hyperledger/fabric-couchdb x86_64-1.0.0-alpha2 3d89ac4895f9 12 days ago 1.51GB
hyperledger/fabric-ca latest 86f4e4280690 12 days ago 241MB
hyperledger/fabric-ca x86_64-1.0.0-alpha2 86f4e4280690 12 days ago 241MB
hyperledger/fabric-kafka latest b77440c116b3 12 days ago 1.3GB
hyperledger/fabric-kafka x86_64-1.0.0-alpha2 b77440c116b3 12 days ago 1.3GB
hyperledger/fabric-zookeeper latest fb8ae6cea9bf 12 days ago 1.31GB
hyperledger/fabric-zookeeper x86_64-1.0.0-alpha2 fb8ae6cea9bf 12 days ago 1.31GB
hyperledger/fabric-orderer latest 9a63e8bac1f5 12 days ago 182MB
hyperledger/fabric-orderer x86_64-1.0.0-alpha2 9a63e8bac1f5 12 days ago 182MB
hyperledger/fabric-peer latest 23b4aedef57f 12 days ago 185MB
hyperledger/fabric-peer x86_64-1.0.0-alpha2 23b4aedef57f 12 days ago 185MB
hyperledger/fabric-javaenv latest a9ca2c90a6bf 12 days ago 1.43GB
hyperledger/fabric-javaenv x86_64-1.0.0-alpha2 a9ca2c90a6bf 12 days ago 1.43GB
hyperledger/fabric-ccenv latest c984ae2a1936 12 days ago 1.29GB
hyperledger/fabric-ccenv x86_64-1.0.0-alpha2 c984ae2a1936 12 days ago 1.29GB
hyperledger/fabric-baseos x86_64-0.3.0 c3a4cf3b3350 4 months ago 161MB

Create your network artifacts

cd examples
cd e2e_cli
./ <channel-ID>

Make sure to choose a channel name for <channel-ID> ie mychannel

then the below to launch the network

CHANNEL_NAME=<channel-id> TIMEOUT=<pick_a_value> docker-compose -f docker-compose-cli.yaml up -d

or use this script to launch the network in one command.

./ up <channel-ID> <timeout-value>
docker ps

To manually run and call the network use

Open the docker-compose-cli.yaml file and comment out the command to run Navigate down to the cli container and place a # to the left of the command. For example:

  working_dir: /opt/gopath/src/
# command: /bin/bash -c './scripts/ ${CHANNEL_NAME}; sleep $TIMEOUT'

Save the file and return to the /e2e_cli directory.

# Environment variables for PEER0
docker exec -it cli bash
peer channel join -b yourchannelname.block
peer chaincode install -n mycc -v 1.0 -p
# remember to preface this command with the global environment variables for the appropriate peer
# remember to pass in the correct string for the -C argument.  The default is mychannel
peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $GOPATH/src/ -C mychannel -n mycc -v 1.0 -p -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org0MSP.member','Org1MSP.member')"
peer chaincode invoke -o orderer0:7050  --tls $CORE_PEER_TLS_ENABLED --cafile $GOPATH/src/  -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}'
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

You now should have a functioning network that you can call.

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

To clean and bring down the network use 

./ 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 This is a great resource for learning about the intricacies of the network and the different certificates needed for trusted transactions.

Hyperledger Fabric Composer

To start building different blockchain applications that interact with your network I recommend using the Fabric Composer platform. This enables you to model out the different participants, assets, and transaction types that will be used on your blockchain network. It also enables you to write the business logic in Javascript. Once you have model out the different elements of your network you can then wire it up and deploy it to the blockchain v1 instance.

To install Fabric Composer visit

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).

If you are running into any trouble feel free to reach out at


5.26 – using v1.0

5.27 – using v1.0 alpha2 docker images and added in fabric composer (current)



11 thoughts on “How to setup and build Hyperledger Fabric Blockchain Applications

  1. I am getting an error when I run the command “./ up mychannel”. Everything works fine up until I get the message:
    Pulling cli (hyperledger/fabric-testenv:latest)…

    Then I get the error:
    ERROR: repository hyperledger/fabric-testenv not found: does not exist or no pull access

    I am logged into docker and was able to pull other images so I was wondering if you know why I am getting this error or if there is another repo I could try to pull the image from.

    Thanks in advance


  2. I ran it in again seperate vm and got the same error. I believe the github repo was updated and the file was changed. Working on an update


  3. hyperledger/fabric-testenv was removed from the project

    “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.”


  4. Updated based on e2e on github.

    Fabric-testenv is still included in the examples/e2e_cli make. I have a a couple VMs that are working as expected prior to the update


  5. FYI: I installed on two Ubuntu 16.04. (AWS and OVH) following this post
    I got the following error: “Channel creation failed”

    Here the details :
    2017-05-18 16:27:38.171 UTC [msp/identity] Sign -> DEBU 011 Sign: digest: E80E700E8C83B19E9B838527D7823DA6F4CE04EDA3D7F3E681146A62CB23E01C
    Error: Got unexpected status: BAD_REQUEST
    peer channel create [flags]

    Global Flags:
    -b, –blockpath string Path to file containing genesis block
    –cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
    -c, –chain string In case of a newChain command, the chain ID to create.
    -f, –file string Configuration transaction file generated by a tool such as configtxgen for submitting to orderer
    –logging-level string Default logging level and overrides, see core.yaml for full syntax
    -o, –orderer string Ordering service endpoint
    –test.coverprofile string Done (default “coverage.cov”)
    -t, –timeout int Channel creation timeout (default 5)
    –tls Use TLS when communicating with the orderer endpoint
    -v, –version Display current version of fabric peer server

    !!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
    ================== ERROR !!! FAILED to execute End-2-End Scenario ==================

    This was a known bug should.It was solved the 31 April 2017, according to JIRA 3042
    but I get the error anyway.

    Do you have any clue? Thanks in advance.


      1. well, the problem is with the channel name:
        if I run the command “./ up” without setting the name, the network starts correctly


        1. FYI: now that the network is up I get another error when joining the channel:

          “2017-05-20 06:56:37.034 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 2FC587D450765B83142C8304E4EB5A2EFC239ABE0E38500916F638A7D5EA67DB
          Error: proposal failed (err: rpc error: code = 2 desc = Cannot create ledger from genesis block, due to LedgerID already exists)
          peer channel join [flags]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s