Git Product home page Git Product logo

hyperledger-composer-dev-tutorial's Introduction

Hyperledger Composer Development Tutorial (MAC OSX)

Use these commands while following along with Part 5 of the Hyperledger Development Series

Prereqs (important!)

See first video in series or visit the official Mac setup documentation for Composer

Please note that if you have been following along with this tutorial series, you will need to run nvm install --lts again as Node has upgraded their long term support version.

Environment Setup Commands

Download hyperledger client and tools (or npm update if you have already installed)

npm install -g composer-cli
npm install -g generator-hyperledger-composer
npm install -g composer-rest-server
npm install -g yo

Clean up your docker containers (careful if using docker containers for other projects!)

docker kill $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images dev-* -q)

Clean up any composer credentials and connection profiles you might have created previously (again, this assumes you don't have any important composer projects already started!)

rm -rf ~/.composer-connection-profiles
rm -rf ~/.composer-credentials

Start Hyperledger Fabric (this is what the business network connects to and is a series of Docker containers).

mkdir fabric-tools
cd fabric-tools
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
unzip fabric-dev-servers.zip
./downloadFabric.sh
./startFabric.sh
./createPeerAdminCard.sh

Project Setup/Deployment Commands

Generate a template with Yo

yo hyperledger-composer:businessnetwork

> Business network name: perishable-network
> Description: A perishable tracking network
> Author name:  zach
> Author email: [email protected]
> License: Apache-2.0
> Namespace: org.acme.shipping.perishable

This is based off of perishable sample network found here.

Create your .bna file

mkdir dist
composer archive create --sourceType dir --sourceName . -a ./dist/perishable-network.bna

Deploy the network

composer runtime install --card PeerAdmin@hlfv1 --businessNetworkName perishable-network
composer network start --card PeerAdmin@hlfv1 -A admin -S adminpw -a perishable-network.bna -f networkadmin.card
composer card import networkadmin.card
composer card list
composer network ping --card admin@perishable-network

The REST server

To connect to REST server with authorization (Github), create new credentials for your application in github, and then put those credentials in the following environment variable and run it.

Install github-authentication

npm install -g passport-github

Export your COMPOSER_PROVIDERS env variable

export COMPOSER_PROVIDERS='{
  "github": {
    "provider": "github",
    "module": "passport-github",
    "clientID": "d25c49eac0dbb40f09b1",                    
    "clientSecret": "1041a7c497721de8e258b1a820d701664b07c698",               
    "authPath": "/auth/github",
    "callbackURL": "/auth/github/callback",
    "successRedirect": "/",
    "failureRedirect": "/"
  }
}'

Now, run the REST server with authentication

composer-rest-server -n perishable-network --card admin@perishable-network -a true -m true

You will need to import your identity card to use the REST server.

hyperledger-composer-dev-tutorial's People

Contributors

zachgoll avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.