Hurley: Setup Development Environments for Hyperledger Fabric

Written by waltermontes | Published 2019/01/10
Tech Story Tags: javascript | hyperledger | development | code | convector

TLDRvia the TL;DR App

As a part of the Convector Suite, we decided to spin out the Dev Env libraries and turn them into an independent project. The main reason for that decision is that we know that it may be overwhelming to deal with the environment while also developing with Hyperledger Fabric and other frameworks. We always see people all the time in chats, channels, and blogs having a hard time with those tasks. It is a problem big enough to be its own product.

If you are not familiar with the Convector Suite take a look at this post: Announcing: Convector, a JavaScript Framework for Smart Contract Systems

The Convector Suite has grown since launch 5 months ago. Initially, it was made only of Convector Smart Contract libraries and a few utils to install and upgrade smart contracts during development.

A Convector Smart Contract looks like the following:

A few months ago, Convector got its own CLI, so setting up a new Convector project became a matter of one command line. Check this example to contrast how a Convector Smart Contract looks like versus vanilla Go or Node in Hyperledger Fabric.

The Convector CLI the best way to start a new project. But it still used fairly simple and fixed development environments.

See the last two commands (npm run env:restart and npm run cc:start -— toke 1)? Those get replaced with the newly created Hurley.

We all know that starting with new technology can be hard, so we are working on making it easier. Hurley is an Open Source project inside the Convector Suite umbrella that enables developers to roll out development networks and streamline the development lifecycle with just a few commands.

Hurley is independent from Convector Smart Contracts. So it can work with it or without it. You can also use it to install and upgrade Golang and vanilla Node chaincode.

Starting with Hurley is quite easy. Its only requirement is having Docker CE up and running. Hurley will even download your Hyperledger Fabric dependencies.

$ npm i -g @worldsibu/hurley

With this, now you can use Hurley in any folder path that you want. For example, let’s download the Fabric Samples to use those examples here.

$ git clone https://github.com/hyperledger/fabric-samples.git$ cd fabric-samples

Start yourself a blockchain network with 3 organizations and 2 users each organization, plus add 2 channels.

$ hurl new --organizations 3 --users 2 --channels 2

Wait a few seconds (maybe minutes if you don’t have Fabric downloaded already).

Now let’s go to the Fabric Samples project that we want to install. Be sure to run hurl install inside the folder where your source code resides.

$ cd chaincode/fabcar/go/$ hurl install fabcar golang

[hurley] - installing smart contract located at /Users/walter/Development/testhackhurley/fabric-samples/chaincode/fabcar/go

...2019-01-07 09:49:08.483 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc2019-01-07 09:49:28.928 CST [main] main -> INFO 003 Exiting.....

Voilà! You have successfully installed a smart contract yourself.

If you were to make a change to the source code, and want to upgrade to code, just make the change and run.

# change 1.2 for the new version of your smart contract$ hurl upgrade fabcar golang 1.2

Hurley streamlines the development lifecycle so that you can focus on business matters, like the design of the smart contract.

After version 1.0.5 of Convector CLI new projects will be generated supporting Hurley instead of the legacy Dev Environment. You can still run the same NPM commands or you can run Hurley commands directly if you installed it globally.

# Install a blockchain$ npm run env:restart

# Install to your blockchain - From the root of your project$ npm run cc:start -- product$ npm run cc:start -- product 1.2

# Install a blockchain$ hurl new

# Package your smart contract's code - From the root of your project$ npm run cc:package -- product org1

# Install to your blockchain - From the root of your projectcd ./chaincode-product$ hurl install product node$ hurl upgrade product node 1.2

The advantage of using Hurley directly is that you can do more complex tasks.

Some examples:

# Install a chaincode with a different name$ hurl install anothernameforyourcc node

# Install a chaincode in a different channel$ hurl install <chaincode> node --channel ch2

# Install a chaincode in a path different than current$ hurl install <chaincode> node -P ./sourcecode/chaincode

Find it helpful? We would love to hear from you. What do you think is the next feature that Hurley or Convector should support? Let us know in the Issues page.


Written by waltermontes | CEO @ WorldSibu
Published by HackerNoon on 2019/01/10