Skip to content

worldsibu/hurley

Repository files navigation

Hurley

Hurley is the development environment toolset for Enterprise Blockchain projects. It supports Hyperledger Fabric and is being ported to support other chain technologies.

It is an open source project under an Apache 2.0 license to help you create Convector projects easily.

Prerequisites

Usage

npm i -g @worldsibu/hurley

Upgrade

npm upgrade -g @worldsibu/hurley

Get Version

Get the version of your Hurley installation.

hurl --version

Hurley deploys Hyperledger Fabric 1.4.0 networks.

Basic network management

# Start a new blockchain network with 2 organizations, 2 users per organization, and 1 channel, localted at ~/Home/hyperledger-fabric-network
hurl new

# Clean every blockchain network deployment component
hurl clean

Details

hurl new

Create a new blockchain network in your computer. The first time you execute it, Hurley will check for Hyperledger Fabric's binaries and Container Images. It will store the container data holding up the blockchain information in a folder inside <path>/data. If this folder gets deleted, the blockchain information is gone. Hurley daletes this folder on every hurl new. If you don't want to delete it, run hurl new --skip-cleanup. It also gets deleted in the hurl clean command.

# New project
hurl new
    [-n --network <path>] # Path to the network definition file
    [-o --organizations <amount-of-organizations>]
    [-u --users <users-per-organization>]
    [-c --channels <amount-of-channels>]
    [-p --path <path-to-install-the-network>]
    [-i --inside] # Whether or not the `hurl` command will runs inside the same Docker network where the blockchain was provisioned
    [--skip-cleanup] Skips cleaning up the <path>/data folder

hurl explorer

Brings up a hyperledger explorer instance, restart if there is a running one

# Runs hyperledger explorer
hurl explorer
    [-p --port <path-to-install-the-network>] # Port where explorer will run (default: "8080")

hurl clean

Clear your environment from all the components.

hurl clean
    [-p --path <path-to-install-the-network>]
    [-R --no-rmi] # Ask `hurl` to not delete the container images

hurl install

Hurley handles the lifecycle of your chaincodes through install and upgrade commands.

Be sure to run hurl install inside the folder with the source code you want to install.

hurl install <chaincode> <language>
    [-o --org <organization>] # Defaults to org1 & org2. Use example: "-o org1 -o org2 -o org3"
    [-p --path <path-to-install-the-network>]
    [-C --channel <channel>] # Defaults to ch1. Use example: "-C ch1 -C ch2 -C ch3"
    [-c --ctor <constructor>] # The constructor for the install function. Defaults to ' {"Args":["init",""]}'
    [-x, --collections-config <collections-config>] # Collections config file path (private data
    [-P --chaincode-path <path>] # Path to chaincode package. Default to ./<chaincode>
    [-i --inside] # Whether or not the `hurl` command will runs inside the same Docker network where the blockchain was provisioned
    [-d --debug] # Runs the chaincode in debug mode, it doesn't start a container, instead it runs the process in your host machine. This is only available for Nodejs chaincodes for now, it will invoke `npm run start:debug`

Language options:

  • node
  • golang

hurl upgrade

Be sure to run hurl upgrade inside the folder with the source code you want to install.

hurl upgrade <chaincode> <language> <version>
    [-o --org <organization>] # Defaults to org1 & org2. Use example: "-o org1 -o org2 -o org3"
    [-p --path <path-to-install-the-network>]
    [-C --channel <channel>] # Defaults to ch1. Use example: "-C ch1 -C ch2 -C ch3"
    [-c --ctor <**constructor**>] # The constructor for the install function. Defaults to '{"Args":["init",""]}'
    [-x, --collections-config <collections-config>] # Collections config file path (private data
    [-P --chaincode-path <path>] # Path to chaincode package. Default to ./<chaincode>
    [-i --inside] # Whether or not the `hurl` command will runs inside the same Docker network where the blockchain was provisioned

Language options:

  • node
  • golang
  • If you are using Convector Smart Contracts be sure to package first the code through npm run cc:package -- <your-chaincode> org1

hurl invoke

You don't to be in any specific folder path, you just need the name of the chaincode.

hurl invoke <chaincode> <fn>  [args...]
    [-o --org <organization>]
    [-p --path <path-where-you-installed-the-network>]
    [-t, --transient-data <transient-data>] # Private data, must be BASE64 https://hyperledger-fabric.readthedocs.io/en/release-1.4/private_data_tutorial.html#store-private-data
    [-u, --user <user>] # Select an specific user to execute command. Default user1
    [-o, --organization <organization>] # Select a specific organisation to execute the command. Default org1
    [-C --channel <channel>] # Defaults to ch1
    [-i --inside] # Whether or not the `hurl` command will runs inside the same Docker network where the blockchain was provisioned
    [--skip-download] # Skip downloading the Fabric Binaries and Docker images

The main parameters here are <chaincode>, <fn>, and [args...] where [args...] is an array of params separated by a blank space, for example:

For Non-Convector-JS based chaincode methods

  • hurl invoke example02 invoke "walter" "diego" "99"
  • hurl invoke example02 query "walter"

For Convector-JS based chaincode methods

  • hurl invoke exampleconv exampleconv_beautifulMethod "walter" "diego" "99"
  • hurl invoke exampleconv exampleconv_beautifulQuery "walter"

Note the prepending of the chaincode (controller) name in the <fn> param.

Network Configuration File

Hurley can setup a network based on a configuration file. This file must be set up as follow:

{
  "channels": ["ch1", "ch2"],
  "topology": {
    "org1": {
      "channels": ["ch1"],
      "users": ["John", "Mike"]
    },
    "org2": {
      "channels": ["ch2"],
      "users": ["Jane"]
    },
    "org3": {
      "channels": ["ch2", "ch1"],
      "users": ["Henry"]
    }
  }
}

Private Data

In recent versions of Hyperledger Fabric, it's now possible to handle private collections of data.

Read here more how to configure smart contracts with private data, and how to make calls to it.

Integrate to your development flow

Everything you need will be hosted in the Network Folder (default $HOME/hyperledger-fabric-network). You can use all the files in this folder to consume the network, whether in your machine or in a Docker container.

Crypto materials for your users

All the certificates and Application files for your default users reside in $HOME/hyperledger-fabric-network/.hfc-*.

Network profiles

Your network profiles will be provisioned at $HOME/hyperledger-fabric-network/network-profiles.

  • The *.network-profile.yaml files: map your network if you run outside of the Docker network. For example, straight from your Machine.
  • The *.network-profile.inside-docker.yaml files: map your network if you run an application inside a docker container in the same network as the blockchain hurley_dev_net.

Roadmap 🗺

Have ideas? Post them in the Issues section.

Some ideas for future releases:

  • Hyperledger version select.
  • Support Hyperledger Sawtooth.

Changelog

Go to changelog

Important ⚗️

This project is currently under development and it's changing fast, but you can use it for your projects and if something doesn't work or would like new features provide feedback. We love community feedback!

Currently based on Fabric Samples from Hyperledger Fabric.

Support