Skip to content

Instantly share code, notes, and snippets.

@saharshagrawal
Last active November 30, 2018 20:42
Show Gist options
  • Save saharshagrawal/06a4aa8c4114ca138bd4201f65a5b79a to your computer and use it in GitHub Desktop.
Save saharshagrawal/06a4aa8c4114ca138bd4201f65a5b79a to your computer and use it in GitHub Desktop.

Hyperleger Dependencies and Business Network Documentation

Install NPM dependencies

npm install -g composer-cli@0.19
npm install -g composer-rest-server@0.19
npm install -g generator-hyperledger-composer@0.19
npm install -g yo
npm install -g composer-playground@0.19

Install Hyperledger Fabric

mkdir ~/fabric-dev-servers && cd ~/fabric-dev-servers
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
tar -xvf fabric-dev-servers.tar.gz

cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv11
./downloadFabric.sh

Instructions for restarting Hyperledger fabric environment

./teardownAllDocker.sh
export FABRIC_VERSION=hlfv11
./createPeerAdminCard.sh
./startFabric.sh

Instructions for Installing Business Network Archive (.bna)

This will require first obtaining a .bna file or generating it manually from the source files, and placing it in the fabric-dev-servers directory.

(Optional) Manual Generation of .bna from Source Files

In the directory containing the script file (.js), models file (.cto), access control file (.acl), and query file (.qry), run the following command:
composer archive create -t dir -n .

Install Existing .bna

This is the current ford-network.bna which is deployed here: http://a77e7f48.ngrok.io/
curl -L -o ford-network.bna "https://drive.google.com/a/berkeley.edu/uc?authuser=1&id=1tkcHLH2Q3p3NKtyZIo6JbDESRdlq9Mf3&export=download"

Make sure to change the name and version of the .bna file when using a different .bna file
composer network install --card PeerAdmin@hlfv1 --archiveFile ford-network.bna
composer network start --networkName ford-network --networkVersion 0.2.6-deploy.34 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin@hlfv1 --file networkadmin.card
composer card import --file networkadmin.card

Instructions for starting REST API's

Start single-user mode REST API on port 3000:

screen
composer-rest-server -c admin@ford-network -n never -u true -w true -p 3000

START multi-user mode REST API on port 3001:

This REST API will require authentication. Many different authentication strategies can be chosen from. We will be using GitHub authentication:

screen

Now export COMPOSER_PROVIDERS by copying all of the following into your terminal. ClientID and ClientSecret can be retrieived by creating a new GitHub application at https://github.com/settings/applications/new and filling in the appropriate API endpoints:
export COMPOSER_PROVIDERS='{ "github": { "provider": "github", "module": "passport-github", "clientID": "59f4e6cd81bda833d4a8", "clientSecret": "8d5af72513cdf9b1ea21a0630409d56b899d7dce", "authPath": "/auth/github", "callbackURL": "/auth/github/callback", "successRedirect": "/", "failureRedirect": "/" } }'

composer-rest-server -c admin@ford-network -n never -a true -m true -u true -w true -p 3001

Instruction for starting Playground GUI on port 8080 (default)

screen
composer-playground

Note: To switch between screen instances, simply type "screen -r" to frist see the available instance, then type "screen -r 1234" where 1234 should be replaced by the id of the screen instance that is desired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment