Deploy an asset-transfer app using blockchain  

Deploy an asset-transfer application on Hyperledger Fabric v1.0

Last updated | By Raheel Zubairy, Nick Gaski

Description

Learn the basics of chaincode and application development within a Hyperledger Fabric network by creating an asset-transfer app that enables you to transfer marbles between multiple owners.

Overview

Updated to support Hyperledger Fabric V1.1

In this developer code pattern, you’ll learn how to migrate from Hyperledger Fabric v0.6 to v1.1. The Marbles application that you’ll build demonstrates a method of transferring marbles between many marble owners using Hyperledger Fabric. You’ll create the app using Node.js and the Go programming language; the backend for the app is written in Go running in a blockchain network. The chaincode will create a marble and store it in the chaincode’s managed state. The chaincode itself can store data as a string in a key/value pair setup. You’ll “stringify” JSON objects to store more complex structures.

The attributes of a marble are as follows:

  • id (a unique string that will be used as a key)
  • color (string, CSS color names)
  • size (int, size in mm)
  • owner (string)

You will create a web-based UI that can set these attribute values and store them in a blockchain. The marble is created in the blockchain storage, or ledger, as a key value pair. The key is the marble ID, and the value is a JSON string that contains the attributes of the marble. To interact with the chaincode, you’ll use the gRPC protocol to a peer on the network. The details of the gRPC protocol are handled with the Hyperledger Fabric Client SDK.

Flow

  1. The administrator interacts with Marbles, our Node.js application, through a browser.
  2. The client-side JavaScript code opens a websocket to the backend Node.js application and instructions are sent to the application from the browser.
  3. The proposal accesses the ledger to simulate a transaction. This proposal is built by Marbles (using the SDK) and then sent to a blockchain peer.
  4. The endorser (process on the peer) will endorse (or sign) the transaction if there are no issues.
  5. The SDK collects all the signed proposals and, if the policy is fulfilled, sends the transaction with the signed endorsements to the ordering service. The orderer service orders the transactions, creates a block, and delivers it to the appropriate peers.
  6. The peer validates the block and writes it to its ledger. The transaction has now taken effect and any subsequent reads will reflect this change.

Related Blogs

Two “edgy” AI TensorFlow models for you!

The global Call for Code is well underway, we want to share some visual recognition models which could help you. These AI models can operate on the edge, which could be particularly useful for this years’ theme: disaster preparedness. How could visual recognition help in relief work? From satellite and drone imagery analysis, to classifying...

Continue reading Two “edgy” AI TensorFlow models for you!

Leveraging the power of AI at Unite Berlin

Last week, from June 19 – 21, we were at Unity’s premiere in Berlin: Unite 2018. This conference brought together Unity’s video game and development community. Unity touches 770 million gamers all over the world and is the market leader for consumer AR and VR use cases and is also rapidly emerging as the market...

Continue reading Leveraging the power of AI at Unite Berlin

Related Links

GitHub

Check out the source code for Hyperledger Composer V0.19.3.

IBM Blockchain

Discover enterprise-level production-ready blockchain services.