Hyperledger (15 pts.)

What you need

Purpose

To practice using Hyperledger Composer to create blockchains customized for specific business use cases.

Background

Hyperledger is a general-purpose framework that can be used to construct blockchain solutions for many business cases. Here's an explanation from the excellent whitepaper, An Introduction to Hyperledger
"Hyperledger serves as a 'greenhouse' that brings together users, developers, and vendors from many different sectors and market spaces. All these participants have one thing in common: All are interested in learning about, developing, and using enterprise blockchains.
Here are the main components currently available for Hyperledger:

Using Hyperledger Composer

In a Web browser, go to:

https://composer-playground.mybluemix.net/login

Click the "Let's Blockchain!" button, as shown below.

In the "playgroundSample@basic-samp..." box, click "Connect now".

The next page shows the available blockchains. The "playgroundSample" blockchain is ready to use, as shown on the left side in the image below.

In the "playgroundSample" box, click "Connect now".


Task 1. Defining the Blockchain

Use Case: Price Tracker

The "About File" explains how this blockchain works. It's a very simple system to track the value of assets.

This blockchain uses four data structures, named Participant, Asset, Transaction, and Event. A Participant owns an Asset, and when the value of it changes, that is recorded by a Transaction. Each value change also triggers an Event to inform other applications of the change.

Model File

On the left side, click "Model File". This file defines the resources in the blockchain, using Hyperledger Composer Modeling Language.

As shown below, the asset object has three attributes: "assetId", "owner", and "value", and the participant object has three attributes: "participantID", "firstName", and "lastName".

You can also see that a transaction has only one attribute: "newValue".

Script File

On the left side, click "Script File". As shown below, this file defines a "sampleTransaction" function, written in JavaScript. The transaction updates the asset registry and creates an event to record the value change.\

Access Control

On the left side, click "Access Control". As shown below, this blockchain allows read access to everyone, and also allows everyone to submit transactions.


Task 2. Using the Blockchain

Now that the blockchain is defined, we need to enter some actual data.

Creating Participants

At the top center, click Test.

The participant registry is empty, as shown below.

At the top right, click the "+ Create New Participant" button.

Delete the code in the black box, and insert the code shown below:

{
  "$class": "org.example.basic.SampleParticipant",
  "participantId": "BG",
  "firstName": "Bill",
  "lastName": "Gates"
}

At the lower right, click the "Create New" button.

Now the registry contains one participant, as shown below.

At the top right, click the "+ Create New Participant" button again.

Delete the code in the black box, and insert the code shown below:

{
  "$class": "org.example.basic.SampleParticipant",
  "participantId": "SJ",
  "firstName": "Steve",
  "lastName": "Jobs"
}
At the lower right, click the "Create New" button.

Now there are two participants, as shown below.

Creating an Asset

On the left side, click SampleAsset. The asset registry is empty, as shown below.

On the top right, click the "+ Create New Asset" button.

Delete the code in the black box, and insert the code shown below.

This code assigns an asset named "MSFT" with a value of "100" to the participant "BG".

{
  "$class": "org.example.basic.SampleAsset",
  "assetId": "MSFT",
  "owner": "resource:org.example.basic.SampleParticipant#BG",
  "value": "100"
}

Click "Create New".

The registry shows the new asset, as shown below.

Performing a Transaction

On the lower left, click the blue "Submit Transaction" button.

Delete the code in the black box, and insert the code shown below.

This code changes the value of the "MSFT" asset to "105".

{
  "$class": "org.example.basic.SampleTransaction",
  "asset": "resource:org.example.basic.SampleAsset#MSFT",
  "newValue": "105"
}

At the lower right, click the blue Submit button.

A box pops up briefly in the upper right saying "Transaction Successful!".


Task 3: Viewing Blockchain Data

On the left side, click "All Transactions".

Everything you've done is recorded on the blockchain, with the newest activity on the top.

Reading from the bottom, creating the blockchain caused four transactions to occur within a couple of seconds, named "AddParticipant", "IssueIdentity", "StartBusinessNetwork", and "ActivateCurrentIdentity", as shown below.

The next four transactions recorded the actions you took: "AddParticipant" twice, then "AddAsset", and, finally, "SampleTransaction".

This is the entire purpose of a blockchain: to keep a complete, accurate ledger of data and all its changes and events, so every stakeholder can inspect and audit it at any time.

In the fourth row from the top, which is an "AddParticipant" entry, on the right side, click the "view record" link.

A "Historian Record" box appears, as shown below. This shows that the user "Bill Gates" was created, with a timestamp and an unique "transactionId".

Close the "Historian Record" box.

Viewing the First Transaction

At the bottom of the "All Transactions" list, in the first record, which is an "AddParticipant" entry, on the right side, click the "view record" link.

As shown below, this record documents the creation of the "admin" account.

Close the "Historian Record" box.

Viewing the "IssueIdentity" Transaction

At the bottom of the "All Transactions" list, in the second record from the bottom, find the "IssueIdentity" entry. On the right side, click the "view record" link.

This record assigned an "identityName" value to the "NetworkAdmin#admin" account, which is covered by a green box in the image below.

Enter the "identityName" value in the form below to record your success.

14: Recording Your Success (15 pts.)

Use the form below to record your score in Canvas.

If you don't have a Canvas account, see the instructions here.

Name or Email:
Redacted Word:

Sources

First Business Network using Hyperledger Composer
An Introduction to Hyperledger

Added to CNIT 123 8-4-18