How to Become a Hyperledger Fabric Developer

Don Li
Coinmonks
Published in
12 min readFeb 4, 2019

--

If late 1990's and early 2000's were the dawn of our Internet age then for today with the arrival of the blockchain technology we are at the cusp of a new paradigm or even value age in a few years time frame or even less. As software developers, if we want to embrace this nascent technology we need to build foundational knowledge of and skill in blockchain technology, thus, gain a good understanding of it and then learn and become familiar some major blockchain platforms such as Hyperledger Fabric would be valuable.

This piece is a bit long, designed to help you get started and get up to speed with such a goal in mind. It entails two parts but altogether you would need four parts.

The first two parts would lay down foundational knowledge of and skill in blockchain technology for you.

The third part is a high level introduction of how to build a PoC blockchain application using Hyperledger Fabric, this part is already published at Medium (more below) and the fourth part is the true gem of all, they are consisted of two sets of well constructed, peer reviewed training materials for Hyperledger Fabric.

What would future hold for blockchain developers?

Part One — Unix/Linux/Ubuntu Essentials

For many of us, we’re so used to mainstream operating systems like Windows and MacOS but infrequently exposed to Unix/Linux/Ubuntu OS here and there. However, the open source world has tons of resources available for Unix-ish operating systems and the blockchain world is very much open source driven, so, for us software developers to be effective in the emerging blockchain technology space we need to start to embrace Unix-ish OS such as Ubuntu. Now, let the learning game begin and may the force be with you!

Before we start, let’s make clear about some coding conventions in this blog. Everything in italic and bold or just italic are commands. And this blog use Ubuntu 16.04 LTS as its base.

First thing first, we need to know our Ubuntu machine and

File/Directory Structures and Most Essential Ubuntu Commands

No matter how you get to your Ubuntu command prompt (via terminal or ssh or another means), we assume you’re now at command prompt. Which may look like this:

Now, say, we want to find out our Ubuntu version.

We would issue the following command:

cat /etc/os-release

All good.

Next, when you open up a terminal to a Ubuntu host computer for the first time, it’s like when you first walk into a house or even a mansion, the first you do, is usually look around to see what’s out there…

With a computer, we want to find out what are the files, software programs ( directories ) etc. are out there.

With Ubuntu or other type of Unix flavored OS, we simply type the following command:

ls

So, now we have a screen that looks like below:

But what if you want to find more info about files and directories? Well, then, you would issue the following command:

ls -l

And now, let’s say, you’re a very curious person, you saw Pictures directory (folder) and what you want to see what’s inside :) What do you do then, simple, just use the following command to “change directory”.

cd

Since you want to change directory to Pictures you would issue the following command:

cd Pictures

And let’s further assume the Pictures directory indeed has a fabulous image that you’ve been dreaming to view all your life! So, you want it to be in your home directory ( ~ ). Now, what? You would simply copy it to your home directory. So, you would use the following copy command:

cp

And let’s say, that fabulous image file is named “goddess.jpg” you would issue the following command to copy it to your home directory.

cp goddess.jpg ../

or

cp goddess.jpg ~

Who knows, you may be a bit shy, so, why not rename that awesome “goddess.jpg” image name to something like “justforme.jpg”, so, how to do that? Simple, just use the mv command and type the following:

mv

mv goddess.jpg justforme.jpg

In the meantime, you also find that your home directory has files that you absolutely do not need. Say, it has some file like ImaUselessfile.txt, so, how do we get rid of it? Simple, just use the rm command and type the following:

rm

rm ImaUselessfile.txt

Ok, now you’re getting to know more about Ubuntu and your boss decided to give you a project to work on. So, you want to create a new directory (folder) to place all related files for this project in one place for better management. How to do that? Simple, use the mkdir command and type the following:

mkdir

mkdir yourNewProject

In the above, we talked about removing files, what if you have directories or folders that you no longer need. How to do that? Simple, use the rmdir command and type the following:

rmdir

rmdir bigfatFolder

Now, what if the bigfatFolder is not empty? Then you would add the “r” (for recursive) and “f” (for force) switches like the following:

rm -rf bigfatFolder

Then, you work on a text file for quite some time and it’s reasonably big, at one point, you just need to find some specific information within? Easy, use the grep command and try something like below:

grep

grep keyword myFolder/myTextfile

So, the grep works like this, grep what from where. And btw, grep stands for g/re/p (globally search a regular expression and print)

And if you need to find file try the find command like this:

find -name myfile

And here’s a screenshot for the output:

How to install new software

Often time we may find that we need to install some software package onto my Ubuntu OS. Here’s how we do it, issue the following command, adding sudo to ensure we are granted with full permissions.

sudo apt-get install somePackage

or

sudo apt install somePackage

How to create and edit files

Since files are our life blood as software developers, so, we need to be able to create and edit files on Ubuntu.

There are several text editors on different versions of Ubuntu. Let’s try the easy to use ones below and you can stick with one you like most.

We have gedit, pico and nano.

gedit myfile

pico myfile

nano myfile

And here’s how the screen looks like for gedit myfile:

Now, what if you just want to see what are the text in the top or bottom portion of your text file? Easy.

Use head or tail commands. See below. They display the top or bottom 10 lines of text of the myfile.

head -n 10 myfile

tail -n 10 myfile

Understanding executable file or shell script

Ubuntu executable files are also called shell scripts. For bash shell script ( vs. csh etc. ), it ends with .sh extension, and it must be set to x to be executable.

How to manage file permissions

Windows OS does not have the notion of file attributes like Read, Write and Executable. Whereas,

Unix/Linux/Ubuntu is very interesting in terms of file security protection!

A file can have three types of attributes of Read (r), Write (w) and Executable (w). And user role wise, it can be one of the following three:

u for current user

g for group

o for others (global)

and a for all

But of course, if you make an image file such as imGoodLooking.jpg executable would be meaningless.

So, let’s say, you’ve created a simple shell script to display key information about all your projects ( it’s already Read and Write for all ) and the script file is called “myProj.sh” and you would everyone to be able to execute it as well. Then you would run the following command:

chmod a+x myProj.sh

The following screenshot will show the file attributes of a shell script named “bootstrap.sh”, as you can tell it’s now executable since u has x, g has x and o has x too:

Understanding Processes

In Unix/Linux/Ubuntu environment, software program is also called “process”. To find out what programs or processes are up and running you would issue the following command:

ps

To run a process, say, myProj.sh you would issue the following command:

./myProj.sh

What’s so interesting is that with Unix/Linux/Ubuntu you may also run any program in the background so that you don’t have to open up many terminals to run various processes. So, how? Simple, just add the & at the end. So, to run the myProj.sh in the background you would issue the following command:

./myProj.sh &

Well, what if you change your mind? That is, you decided to stop a running process. Easy, just kill it. First, use the ps command to find its pid ( process id ), and say the pid is 1234 and then issue the following command to terminate it:

kill 1234

Redirect or Pipes

You may find the following two redirect or pipes facility in Unix/Linux/Ubuntu very useful.

First, you can redirect screen output to a text file. For instance, you want to find out what files and directories are in your home directory and you want to send such info to yourself via email. Then, you could simply type the following command:

ls > myFilesDirectoryStructure.txt

Then, you can simply attach the myFilesDirectoryStructure.txt in your email.

And you can use >> to append text to an existing file like below:

cat new content >> myFile.txt

Now what if you have multiple processes and you want to map the output of one process to be an input for another process? It’s easy, see the following command:

./myProcess1.sh | ./myprocess2.sh

Pay attention to the | symbol between the above two commands.

Basic networking

The most important thing about networking is the interfaces file under /etc/network directory.

By default, it may look like below:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

But you need to add something like below:
auto enp0s8
iface enp0s8 inet static
address 192.168.56.110
netmask 255.255.255.0

Use ifconfig command to find enp0s8 is in the list, if so, the above would be fine otherwise, replace it.

The address does not have to be 192.168.56.110 but something similar. And then this address would be accessible for services.

How to manage user account

Suppose you are asked to create another user account for your Ubuntu, you can simply issue this command:

sudo adduser newuser

Misc

Before we install new software package we may want to find our current disk space usage. To do so, type the following command:

df -BG

Your screen may look like below:

Additional Tips

Ubuntu is a case-sensitive, all commands, file names, directories, etc are case sensitive.

For files and folders having spaces in them. i.e. “Program Files”, “My Documents”, “My Pictures”, etc. use double quotes to reference them in command lines.

Where do we go when you’re stuck

Inevitably we’ll have questions or problems using Ubuntu, then what?

Try askUbuntu.com

Try stackoverflow.com

In addition, our old friend, google.com

Wow, we’ve just covered quite a bit of info about Ubuntu already, you don’t have to know them all in a single breath, but having a good grasp of its essentials would definitely be a good start.

Enjoy! Happy learning!

Part Two — Docker Essentials

Started in last few years the information technology industry loves containerization because such technology makes software application easily portable. Docker is the king in the containerization space, and the blockchain technology embraces containerization as well. Thus, Docker is a hottie now. That’s why we as blockchain developers need to get a grasp of it.

In this short writing, we’ll focus on the two practical aspects of Docker.

The first, what essential Docker commands that we need to know, and the second, what Docker commands would be needed for running a web application server as a Docker container. In case you wonder why these two aspect of Docker are most important for blockchain developers, Part Three will explain that.

Essential Docker Commands

Before we start, two things have been assumed.

(a) You’re on a Ubuntu OS platform, native or virtual machine. To run Ubuntu virtual machine you may download and install Oracle VM Virtualbox.

(b) Docker has been installed (Part Four contains a script that would automatically install Docker for you).

Now, let’s get started!

Conceptually, Docker works like this. You download and install some software package as a docker image or multiple docker images, and then, you create/build docker container(s) based on such image or images, and then you can run these containers to provide certain services.

Download and Install Docker Image

To do so, you would simply issue the following command:

docker pull somedockerimage

And of course you need to be online. Installation is automatic.

Docker Image Verification

Once downloaded, you would issue the following command to verify its completion:

docker images

Then, your screen may look like below:

Docker Image Management

To find out what docker containers are up and running you would issue the following command:

docker ps

To go a step further, that is, to find out all docker containers you would execute the following command:

docker ps -a

And let’s say, something is not working, so, you want to delete running containers. In this case, you would issue the following commands:

docker rm $(docker ps -qa)

Even better, use the following command to stop running containers:

docker stop $(docker ps -qa)

Some Docker Trouble-shooting Tips

To clean up your docker networks you would issue the following command:

docker network prune

When prompted with “Are you sure you want to continue?” type “y” to say “yes”.

To clean up your docker volumes you would issue the following commands:

docker volume prune

When prompted with “Are you sure you want to continue?” type “y” to say “yes”.

Docker Commands for Docker Image as Web Application Server

As a web application developer creating web applications integrating with a blockchain you would find that using a docker image as a web server is very handy.

First thing we need to download a web application server. Say, you like Lucee, so here we go:

docker pull lucee/lucee4

Next, you want to create some directories or folders for Lucee. The following commands would do.

mkdir lucee

cd lucee

mkdir www

So, now we have /lucee/www

Next, we need a Dockerfile for Lucee. It may read as simple as below:

FROM lucee/lucee4:latest

COPY www /var/www

Next, create some server side scripts and place them in the /lucee/www directory.

Now, we’re ready to build some Lucee container. It’s simple. First, go to lucee directory.

cd luee

and then, type some command like below:

docker build -t myapp .

Don’t forget the period . symbol at the end. To verify if it has been built, issue the docker images command.

Next, we can run it like this:

docker run — -rm -p 8888:8888 myapp (two dashes before rm)

Now, you can load your server side scripts via a web browser at port 8888.

And if you want to kill it, simply press Ctrl + c together.

And if you need to stop a container first use “docker ps” to find running container’s id and then issue the following command:

docker stop {containerid}

That’s it!

The following professionals have been kind enough to proofread the above two parts, so, let us thank them here as well: Biser Dimitrov, Jorden Seet and Dr. Reza Parizi.

Part Three — Build a Blockchain PoC Application using Hyperledger Fabric

Part Four — Two sets of Hyperledger Fabric training materials including source code.

Available for a fee. For details, contact me at lichunshen84 at gmail.com

In sum, part one and two are like the ingredients, part three is like salad or appetizer but part four is the main course, the “meat and potato”!

And let me end this long piece by quoting an MIT professor, A. Sanchez, on the future work in the blockchain space, “It’s still very early in the game, so there is going to be that market for the hot shot blockchain technologist who will build systems and can hop from company to company and make a ton of money. But, if the promise comes through on the potential, there will be a lot of work in this space for many years, even a decade or more. This will be entrenched and deeply connected into the enterprise. It will be making money. It will be a core piece of the infrastructure.”, but I have to say, it would require a lot of learning and work. And YES, it will pay off!

--

--