Hyperledger Fabric By Example: Part 1

2019 feels like it is the year to learn about distributed ledger technologies, aka. blockchain.

What / Why Hyperledger Fabric?

Hyperledger Fabric is an open source enterprise-grade permissioned distributed ledger technology (DLT) platform, designed for use in enterprise contexts, that delivers some key differentiating capabilities over other popular distributed ledger or blockchain platforms.

— Hyperledger Fabric — Introduction

As for why; “You are only as good as your team.”

Why This Series?

In learning Hyperledger Fabric, I started by reading Hyperledger Fabric’s conceptual documentation. With my head spinning with new concepts, I dove into their hands-on tutorial, Writing Your First Application.

It did not go well; I struggled to connect the hands-on steps back to the concepts. In this series, we will revisit the hands-on tutorial; this time exploring the concepts and software components in detail as we go.


If you are looking to follow along, you will need to install both the prerequisites and fabric-samples.

note: Contrary its appearance, the fabric-samples installation also includes the Hyperledger Fabric binaries (command-line tools and Docker images).

Software Components

In going through the documentation, one fundamental challenge was determining the boundary between their (Hyperledger Fabric) software and mine (operator / developer); e.g., their hands-on tutorials heavily depended on shell scripts (theirs or mine?)

In preparing to write this series, I came to a working assumption on their software components (will revise later if I learn otherwise).

Docker Images

Their server software is delivered through Docker images available on Docker Hub, e.g., hyperledger/fabric-peer.

Command-Line-Interface (CLI) Tools

The fabric-samples installation provides a number of command-line-interface tools; used to control the Docker images; through configuration files or API calls.

Hyperledger Fabric SDKs (NPM packages)

The Hyperledger Fabric SDKs (we will focus on the Node.js SDK) control the Docker images in much the same way as the CLI tools do. They are delivered through two NPM packages fabric-client and fabric-client-ca.

Chaincode Interface (NPM package)

Finally, there is the NPM package, fabric-shim, that provides a mechanism for developing smart contracts, aka., chaincode, in JavaScript.

The Magic

The first step in the Writing Your First Application tutorial is:

Launch your network using the startFabric.sh shell script. This command will spin up a blockchain network comprising peers, orderers, certificate authorities and more. It will also install and instantiate a javascript version of the FabCar smart contract which will be used by our application to access the ledger. We’ll learn more about these components as we go through the tutorial.

— Hyperledger Fabric — Writing Your First Application

What?!? There is quite a bit of magic here. So much so, I needed to break out of character and use one of my favorite images as it perfectly captures my feelings around magic.

Rather, we will dissect startFabric.sh and (hopefully) tie everything back to the concepts and software components.

1/19/2019 Update: After dissecting startFabric.sh, it appears that they took some undocumented short-cuts; switching to dissecting the similarly magical byfn.sh script in the separate Hyperledger Fabric Building Your First Network tutorial. In this tutorial, they dive a bit more into what the script actually does (and hopefully do not take the same undocumented short-cuts).

Next Steps

In the next article, Hyperledger Fabric By Example: Part 2 , we begin to dive into the details