How to start a Hyperledger Fabric blockchain network in 4 minutes

Jakub Dzikowski
SoftwareMill Tech Blog
3 min readMar 25, 2021

--

Fablo is an Open Source Project created by Piotr Hejwowski and Jakub Dzikowski at SoftwareMill

Hyperledger Fabric blockchain is complex. Three node types (Certificate authorities, orderers, and peers), various abstractions over the state (organizations, channels, private data collections), smart contracts, or channels in different programming languages. Anchor peers, endorsers, MSPs, service discovery, you name it.

But sometimes… sometimes you just need to start a simple Hyperledger Fabric blockchain network. Change the topology, start it again, upgrade a chaincode, test it a little bit, and so on. You don’t want to rewrite tons of YAML files and maintain shell scripts where a single typo can cost you a few days of debugging.

And that’s where Fablo comes in. Working with a local Hyperledger Fabric network might actually be simple.

How to start a network in 3 steps

All you need is a working terminal (Linux or macOS) and Docker.

1. Download the current version of Fablo

It is distributed as a single shell script file that can be added to your PATH and used globally or kept independently in your project directory. You can download the most recent version from GitHub or use the following one-liner:

curl -Lf https://github.com/softwaremill/fablo/releases/download/0.2.0/fablo.sh -o ./fablo && chmod +x ./fablo

The script above uses the recent, 0.2.0 version. For more options you can check the installation instructions.

2. Create default network configuration

Fablo comes with a handy command to create the initial network configuration. Just execute:

./fablo init

This comment will create a Fablo config file (fablo-config.json). This is a single source of truth for the Hyperledger Fabric network config. You can examine it and see the configuration of the orderer, organizations, channels, chaincodes, etc. Besides, the command ./fablo init node generates a sample Node chaincode as well, so your network is going to be fully operational.

3. Start the network

To start the network, execute:

./fablo up

Wait a minute or two and you have a fully functional Hyperledger Fabric network running on Docker. The initial network consists of:

  1. Root organization with Root CA and solo orderer.
  2. One organization with CA and two peers.
  3. One channel with a sample Node chaincode installed.

It has the following topology:

The network is fully operational. You can enroll and register users, invoke or query the chaincode. Default CA for organization is available at localhost:7031 (with admin access admin /adminpw). Peers are available at localhost:7060 and localhost:7061. You can invoke this chaincode from CLI or any client.

Besides, you can find the fablo-target directory with all Docker and Hyperledger Fabric configuration.

More complex examples

Fablo enables you to make complex experiments with network topology. Defining the network is simple and declarative. It allows you to quickly examine how the network behavior changes when you add an organization, channel, or when you change endorsement policy. It suits well for continuous integration processes when you need to reproduce the exact network state.

Obviously, you may want to use RAFT instead of Solo consensus, add more organizations, channels, and chaincodes. Just change the fablo-config.json file or use our samples. Then recreate the network with the ./fablo recreate command.

One of our samples reflects the following network:

Feel free to experiment with the fablo-config.json. It has a JSON Schema file linked, so the IDE should provide a decent syntax highlighting.

What’s next?

To get a better understanding, watch Fablo in action in a demo video by Piotr Hejwowski.

You may visit Fablo on GitHub and browse the documentation, check available commands and browse sample network configuration files. There is a good chance you will find our tool valuable for your project.

Finally, all contributions are welcome. Feel free to submit an issue or resolve one.

--

--