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

Written by waltermontes | Published 2019/08/31
Tech Story Tags: blockchain | hyperledger | hyperledger-fabric | network | setup-fabric | fabric | install-fabric | latest-tech-stories

TLDR 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.via the TL;DR App

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.

Written by waltermontes | CEO @ WorldSibu
Published by HackerNoon on 2019/08/31