Learn how to develop blockchain solutions using Hyperledger Composer on Hyperledger Fabric Version 1.0+. This 15 chapter tutorial takes you from no experience to building a complete blockchain application.
- Application developers interested to learn how to build blockchain applications.
What is Blockchain? Concept and architecture overview
What is the architecture of IBM Blockchain? At the end of this video, you should have a basic grasp of IBM Blockchain and the specific problem we're solving with this technology.
What's the story we’re going to build?
IBM Global Finance implemented a shadow Blockchain to address dispute resolution. We will implement a similar story, using the following roles: Buyer, Seller, Third Party Provider, Shipper, Finance Company.
Architecture for the story
Multiple facets are to be taken into account when architecting a blockchain application:
- the typical blockchain components
- the data structures of the ledger
- the ways an application can interact with the ledger
- the way our application will interact with the ledger via Hyperledger Composer.
We will go through each of these topics and finish with the architecture overview of the solution that we will be building.
Set up local Hyperledger Fabric V1 development environment
Hyperledger Composer is an open source tool that sits on top of Hyperledger Fabric. It provides a simplified approach to building Blockchain applications. In this chapter, we will use an automated approach to installing this development environment in OSX and Ubuntu. Windows users will install VirtualBox (free) and then, in the VirtualBox environment, install an Ubuntu-based development environment.
Build and test the network
The network in Hyperledger Composer is defined by creating a:
- Model file (sample.cto), which describes the members, transactions and assets in the network
- Access control file (permissions.acl)
- Transaction logic (/lib/sample.js)
- Test logic (/test/sample.js)
We will create each of these files and then use both the Composer Playground on Bluemix and also the REST services to interact with our first network.
Administration user experience
In this chapter we build our first web front end to our blockchain network. We will start with the administrative interface, which supports the basic management of the network (deploy, undeploy, ping, update) and working with Members and Assets. You will note that there is an option to pre-load the network and that, in addition to what you saw in the video, there is now an active window at the bottom of your browser which is showing all of the blocks as they are created and added to the block chain.
Buyer support and user experience
The Buyer is the beginning of the process. They have the ability to create orders, submit a purchase request, cancel an order, approve payment for an order and raise a dispute. They are the only role, other than the administrator, who can create an Order asset. They can issue some transactions, but not all. We need to interact with the composer created transactions and leverage the ACL to ensure that the buyers can do what they need, while restricting them from issuing inappropriate transaction requests.
Seller support and user experience
The Seller accepts requests to purchase an order, they submit orders to third party providers, request payment when the order has been delivered and resolve disputes.
Provider support and user experience
The Third Party Provider receives a request to deliver an order from the Seller. They send a Shipping Request to the Shipper (next chapter) and can also Resolve a dispute.
Shipper support and user experience
The Shipper receives a Request to Ship from the Provider. It initiates Delivery and can update Delivery Status multiple times before issuing a Delivered transaction. The Shipper has the ability to Resolve a dispute
Finance company support and user experience
The Finance Company is responsible for ensuring that disputes are resolved and that the seller is paid appropriately. This chapter focuses on the Finance Company. By now we've created 5 different views and implemented nearly all of the functionality required on the server side. We have to add a single new service on the server and replicate the changes we've been making for the other user experiences, this time for the Finance Company. We also need to now provide a detailed view of the history of an order, which we have maintained through our transaction chain code.
Combining for demonstration
In this chapter, we bring the four core roles onto a single page to simplify demonstrating the blockchain. This chapter is primarily an exercise in HTML and CSS.
Events and automating for demonstration
Events help us understand and act on what's happening in the network. In this chapter, we will update our system model to support events for each state change in an order and then update the chain code to issue these events if a transaction successfully completes. We then update our nodejs server code to listen for these events and then let the browser know about events as they relate to various roles. We will create an event notification icon and update it in real time as events occur in the blockchain business network.
Published 17 November 2017
Follow IBM Redbooks
Follow IBM Redbooks