paint-brush
Hyperledger Fabric: create a Blockchain Network in under 10 minutes [no scripts]by@waltermontes
1,169 reads
1,169 reads

Hyperledger Fabric: create a Blockchain Network in under 10 minutes [no scripts]

by Walter MontesAugust 31st, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Hurley is a tool to create immutable setups for development blockchain networks with just one command. Hurley manages your development network but also helps you install your chaincode and calling it. Once you deploy the network you can't change the environment through the tool. You can manually do it, but I'd advice against it, for development you want something clean and easy to start/kill in a predictable way. You send the params as an array separated by a blank space. The resulting data of the transaction is sent to CouchDB.

Company Mentioned

Mention Thumbnail
featured image - Hyperledger Fabric: create a Blockchain Network in under 10 minutes [no scripts]
Walter Montes HackerNoon profile picture

One of the biggest pains of getting started with Fabric, even though it's a powerful framework, is getting the infrastructure to work. This small tutorial will get you up and running in less than minutes. No script. No pain.

I'm still surprised how hard it is for some people to get started with Fabric, I know that many just quit because they feel like it's not worth it.

Hurley is a tool to create immutable setups for development blockchain networks with just one command.

Just be sure you meet Fabric requirements:

  1. NodeJS 8.1x - install NVM if you have a latter version.
  2. If you are using Ubuntu or other Linux distros it may be good to follow this guide: https://docs.worldsibu.com/article/120-install-on-ubuntu
  3. Install Docker Community Edition (CE).
  4. Install the CLI tool:
  5. npm install -g @worldsibu/hurley


All good so far? Now to create a network you need to do:

hurl new

This will create a default network in your local Docker.

  • Two organizations
  • Two peers, one CouchDB each

What if you want more organizations or channels?

hurl new -o 3 -c 3

This will create 3 organizations with three channels ready to be used.

Beware that Hurley creates immutable setups, once you deploy the network you can't change the environment through the tool. You can manually do it, but I'd advice against it, for development you want something clean and easy to start/kill in a predictable way.

Hurley not only manages your development network but also helps you installing your chaincode and calling it.

Get into the source code of your project to install it like.

If using golang:

hurl install yourchaincode golang

If using node:

hurl install yourchaincode node
Haven't bootstrapped your own project yet? I'm leaving some instructions at the end of this file on how to create a new project for nodejs with Convector in the section "Actual example with a new chaincode".

Once you have installed your chaincode you can send transactions like this:

hurl invoke yourchaincode invoke "param"

You send the params as an array separated by a blank space.

Actual example with a new chaincode:

# Install a tool to bootstrap your project
npm i -g @worldsibu/convector-cli

# Create a new smart contract code project
conv new example

# get to the project to see the source code
cd example

# Resolve dependencies
npm install

# Package the project
npm run cc:package -- example org1

# Start your blockchain network
hurl new

# Install the smart contract
hurl install example node -P ./chaincode-example

# Wait a few seconds

# Send the first transaction
hurl invoke example example_create '{"id":"1", "name": "example", "created": 1000, "modified": 10000}'

Now you can go to the CouchDB installed by Hurley to see the resulting data of the transaction: http://localhost:5084/_utils/#database/ch1_example/_all_docs

Other interesting content for you once using Hurley:

Next steps

Looking for a great open-source community to ask, grow, and share? Join the Discord channel, there are hundreds of devs interacting everyday.

WorldSibu is the creator of Hurley and it's provided under an Apache 2.0 license. Here's the source code if you'd like to check it out.