Member preview

Blockchain Application Demo

Making blockchain applications are way way too confusing.

Lets try to cut through some of this complex stuff and take some notes to make it easier for others.

Build out plan:

  • Hyperledger
  • AWS EC2
  • Hyperledger Composer

WTF is all of this?

Briefly, we want to use Blockchain for a few reasons. It works as a storage solution just like a database. However Blockchain has some built in advantages. These advantages come out of its unique design and theoretical concept. These concepts are not particularly important for a Blockchain Application Developer, but understanding how to use these advantages is of the upmost importance.

Programmy Setup

# Not working anymore
# curl -O
curl -O
chmod u+x

logout out of the ssh session with the terminal shortcut


then ssh back into the machine

npm install -g composer-cli
npm install -g composer-rest-server
npm install -g generator-hyperledger-composer
npm install -g yo
npm install -g composer-playground

now we have all the tools ready we need to actually install and start a hyperledger chain!

thats easy too — we just download and unzip the provided scripts from Hyperledger and create a default PeerAdminCard to issue IDs to other users.

Cards are very important and we will be tackling them later.

mkdir ~/fabric-tools && cd ~/fabric-tools
sudo apt-get install unzip
curl -O

Now you have a running Hyperledger blockchain on an EC2 instance. If you don’t believe me try running:

docker ps

Now we can see all the containers started! They’re named accordingly.

Okay big woop — who cares we need to add some functionality and colors and buttons and stuff.

Access UI

Okay okay, now we wants to get as far away from this terminal and get our hands on some of those tools we installed (awesome tool kit).

Heres what were going to interact with

  • Hyperledger Composer Web App
  • Hyperledger API test page
  • REST endpoints for Network

To do this we just need to start the right programs and open the correct ports — also we probably should start a small Business Network to play with!

CTRL + B + D

Now we open the port 8080 on the security group in AWS

Editing inbound/outbound rules for Instance

now… we should be able to see the Composer Web App at your instances Public-Ip:8080 in my case its


and you can even see out PeerAdmin as the first card — this card isn't associated with any Business Network; we just think of them as the the Chain admin — only using them to start new chains and add other admin like cards.

Quick Check:

  • We’ve started an AWS instance
  • We’ve installed Hyperledger
  • We’ve installed tools to make dealing with Hyperledger manageable
  • We’ve created a local Network Admin role for deploying chains
  • We’ve played around with the demo cases a bit
  • We’re killing it

Now were going to add a small app to the chain.

Our App is called Promise

Promise, is a simple application that is built on Blockchain technologies and hopefully will have an iOS UI so people can see how simple using Blockchain can be!

Promise ©

Idea: We often find ourselves making commitments, contracts, agreements or promises with other people.

This app allows a Person to make a promise and another person to agree. If both users agree the promise had been completed they can communicate this to the “Promise contract” on the Blockchain, and when both users agrees its been complete it will return as done.

This idea is to be extended with a penalty for the promise maker if they do not complete and expected competition dates. Also people who keep promises will be rewarded reputation points in future builds.

“make Promises that don’t break on the Blockchain, make a promise without trust”

Model psudeo code

- Person
- Promise
- Complete

Model actual code:

asset Promise identified by titleId {
o String titleId
→ Person maker
→ Person taker
o String information
o Boolean makerComplete optional
o Boolean takerComplete optional
o Boolean isComplete optional
participant Person identified by personId {
o String personId
o String firstName
o String lastName
o Double reputation
transaction CompleteTask {
→ Promise myPromise

Okay lets get out own network over to this machine — we’ll use the command scp to achieve this.

scp -i ~/Downloads/hyper-ledger-app-key.pem /Users/davidholtz/2018/Projects/pinky/pinky\@0.0.1.bna

Now pinky\@0.0.1.bna is sitting in our root directory of this EC2 instance. We can deploy this network on our chain using that PeerAdmin identity we created earlier.

composer network deploy -a pinky\@0.0.1.bna -A admin -S adminpw -c PeerAdmin@hlfv1 -f networkadmin.card
Deploying out network to the Blockchain!

This is the part that is the most tricky for me — and seems to hold a huge amount of the power/potential: Cards.

We just created a new card when we deployed that network with a user called admin. We wrote this identity to a card networkadmin.card and now we want to make sure that card is added to composers knowledge. We check and import the card by running the following:

composer card import --file networkadmin.card
Check — Import—Check

By checking before and after the command we see that we added admin@pinky who is called admin on the pink network to the Connection Profile of our Blockchain. Yes I know this bit is confusing (but is important)

okay, checking the UI everything looks good here too!

We see the new admin@pinky card added to our Blockchain

Interacting outside of UI

We are doing great, we have a custom Blockchain App deployed and now we want to make it accessible outside of this useful Hyperledger Composer UI.

Good thing this process has been automated too. We are going to use a program called Loopback to generate out REST endpoints. Thanks to things like Swagger this process was automated by the hyperledger team. We just run a few commands to get this REST engine up and running.

composer-rest-server -c admin@pinky
CTRL + B + D

Cool, now thats running in the background on port 3000. Once again we’ll visit the AWS security groups and add 3000 as an accessible port so we can access it outside of the instance.

Add 3000 to the open ports

Save, and navigate to We are returned a landing page describing what endpoints we have and how to interact with them.

Any developer familiar with REST, can figure out how to build an app from here!

Further Topics

  • Coving multiuser sign in
  • Covering OAuth2 auth for users.
  • Adding custom UI for our App
  • Testing functionality
  • Key management with OAuth2 and Hyperledger Idenities
Please clap if you liked this article! 😊
Any questions please drop a comment 😊