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...
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.
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.
- The administrator interacts with Marbles, our Node.js application, through a browser.
- 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.
- The endorser (process on the peer) will endorse (or sign) the transaction if there are no issues.
- 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.
- 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.