WARNING: This repository is no longer maintained :warning:
This repository will not be updated. I will check periodically for pull requests, but do not expect a quick response.
Read this in other languages: 中国語,日本語.
Build Blockchain Insurance Application
This project showcases the use of blockchain in insurance domain for claim processing. In this application, we have four participants, namely insurance, police, repair shop and the shop. Furthermore,
each participant will own its own peer node. The insurance peer is the insurance company providing the insurance for the products and it is responsible for processing the claims. Police peer is responsible for verifying the theft claims. Repair shop peer is responsible for repairs of the product while shop peer sells the products to consumer. The value of running this network on the IBM Blockchain Platform is that
you can easily customize the network infrastructure as needed, whether
that is the location of the nodes, the CPU and RAM of the hardware, the
endorsement policy needed to reach consensus, or adding new organizations and members to the network.
Note: This code pattern can either be run locally, or connected to the IBM Blockchain Platform. If you only care
about running this pattern locally, please find the local instructions here.
Audience level : Intermediate Developers
When the reader has completed this code pattern, they will understand how to:
- Create a Kubernetes Cluster using the IBM Kubernetes Service
- Create an IBM Blockchain service, and launch the service onto the Kubernetes cluster
- Create a network, including all relevant components, such as Certificate Authority, MSP (Membership Service Providers),
peers, orderers, and channels.
- Deploy a packaged smart contract onto the IBM Blockchain Platform by installing and instantiating it on the peers.
- Use the connection profile from IBM Blockchain Platform to create application admins, and submit transactions from our
client application.
- View transaction details on our channel from IBM Blockchain Platform.
Application Workflow Diagram
- The blockchain operator creates a IBM Kubernetes Service cluster (32CPU, 32RAM, 3 workers recommended) and an IBM Blockchain
Platform 2.0 service.
- The IBM Blockchain Platform 2.0 creates a Hyperledger Fabric network on an IBM Kubernetes
Service, and the operator installs and instantiates the smart contract on the network.
- The Node.js application server uses the Fabric SDK to interact with the deployed network on IBM Blockchain Platform 2.0.
- The React UI uses the Node.js application API to interact and submit transactions to the network.
- The user interacts with the insurance application web interface to update and query the blockchain ledger and state.
Included Components
- IBM Blockchain Platform V2 Beta gives you total control of your blockchain network with a user interface that can simplify and accelerate your journey to deploy and manage blockchain components on the IBM Cloud Kubernetes Service.
- IBM Cloud Kubernetes Service creates a cluster of compute hosts and deploys highly available containers. A Kubernetes cluster lets you securely manage the resources that you need to quickly deploy, update, and scale applications.
Featured technologies
- Hyperledger Fabric v1.4 is a platform for distributed ledger solutions, underpinned by a modular architecture that delivers high degrees of confidentiality, resiliency, flexibility, and scalability.
- Node.js is an open source, cross-platform JavaScript run-time environment that executes server-side JavaScript code.
- React A declarative, efficient, and flexible JavaScript library for building user interfaces.
- Docker Docker is a computer program that performs operating-system-level virtualization. It was first released in 2013 and is developed by Docker, Inc.
Watch the Video - Multiple Organization and Multiple Peer App Demo #1 - Intro
Watch the Video - IBM Blockchain Tutorial: Multiple Organization and Multiple Peer App Demo #2 - Build Nodes
Watch the Video - Multiple Organization and Multiple Peer App Demo #1 - Intro
Prerequisites
We find that Blockchain can be finicky when it comes to installing Node. We want to share this StackOverflow response - because many times the errors you see with Compose are derived in having installed either the wrong Node version or took an approach that is not supported by Compose:
Steps
Steps (Local Network)
To run a local network, you can find steps here
Steps (Cloud Network)
- Create IBM Cloud services
- Build a network - Certificate Authority
- Build a network - Create MSP Definitions
- Build a network - Create Peers
- Build a network - Create Orderer
- Build a network - Create and Join Channel
- Deploy Insurance Smart Contract on the network
- Connect application to the network
- Enroll App Admin Identities
- Run the application
Important Note: This pattern is more advanced because it uses four organizations. For this reason, you will likely
have to get a paid kubernetes cluster to run this pattern on the cloud, since a free cluster will not have the CPU/storage
necessary to deploy all of the pods that we need to run this pattern. There are other patterns that leverage a free
Kubernetes cluster (and only two organizations), so if you want to try that one out first, go here.
Step 1. Create IBM Cloud services
Create the IBM Cloud Kubernetes Service. You can
find the service in the Catalog. Note that for this code pattern, we need to use the 32CPU, 32GB RAM cluster.
Once you reach the create a new cluster page you will need to do the following:
- Choose standard cluster type
- Fill out cluster name
- choose Geography: North America
- Choose Location and availability: Multizone
- Choose Metro: Dallas
- Choose Worker nodes: Dallas 10 only
- Choose Master service endpoint: Both private & public endpoints
- Choose Default worker pool: 1.12.7 (Stable, Default)
- Choose Master service endpoint: Both private & public endpoints
- Choose Flavor 32 Cores 32GB RAM, Ubuntu 18
- Choose Encrypt local disk Yes
- Choose Worker nodes 3
- Click on create cluster.
The cluster takes around 15-20
minutes to provision, so please be patient!
After your kubernetes cluster is up and running, you can deploy your IBM Blockchain Platform V2 Beta on the cluster. The service walks through few steps and finds your cluster on the IBM Cloud to deploy the service on.
Once the Blockchain Platform is deployed on the Kubernetes cluster, you can launch the console to start operating on your blockchain network.
Step 2. Build a network - Certificate Authority
We will build a network as provided by the IBM Blockchain Platform documentation. This will include creating a channel with a single peer organization with its own MSP and CA (Certificate Authority), and an orderer organization with its own MSP and CA. We will create the respective identities to deploy peers and operate nodes.
Create your insurance organization CA
- Click Add Certificate Authority.
- Click IBM Cloud under Create Certificate Authority and Next.
- Give it a Display name of
Insurance CA.
- Specify an Admin ID of
admin and Admin Secret of adminpw.
Create your shop organization CA (process is same as shown in gif above)
- Click Add Certificate Authority.
- Click IBM Cloud under Create Certificate Authority and Next.
- Give it a Display name of
Shop CA.
- Specify an Admin ID of
admin and Admin Secret of adminpw.
Create your repair shop organization CA (process is same as shown in gif above)
- Click Add Certificate Authority.
- Click IBM Cloud under Create Certificate Authority and Next.
- Give it a Display name of
Repair Shop CA.
- Specify an Admin ID of
admin and Admin Secret of adminpw.
Create your police organization CA (process is same as shown in gif above)
- Click Add Certificate Authority.
- Click IBM Cloud under Create Certificate Authority and Next.
- Give it a Display name of
Police CA.
- Specify an Admin ID of
admin and Admin Secret of adminpw.
Use your CA to register insurance identities
- Select the Insurance CA Certificate Authority that we created.
- First, we will register an admin for our Insurance Organization. Click on the Register User button. Give an Enroll ID of
insuranceAdmin, and Enroll Secret of insuranceAdminpw. Click Next. Set the Type for this identity as client and select org1 from the affiliated organizations drop-down list. We will leave the Maximum enrollments and Add Attributes fields blank.
- We will repeat the process to create an identity of the peer. Click on the Register User button. Give an Enroll ID of
insurancePeer, and Enroll Secret of insurancePeerpw. Click Next. Set the Type for this identity as peer and select org1 from the affiliated organizations drop-down list. We will leave the Maximum enrollments and Add Attributes fields blank.
Use your CA to register shop identities (process is same as shown in gif above)
- Select the Shop CA Certificate Authority that we created.
- First, we will register an admin for our Insurance Organization. Click on the Register User button. Give an Enroll ID of
shopAdmin, and Enroll Secret of shopAdminpw. Click Next. Set the Type for this identity as client and select org1 from the affiliated organizations drop-down list. We will leave the Maximum enrollments and Add Attributes fields blank.
- We will repeat the process to create an identity of the peer. Click on the Register User button. Give an Enroll ID of
shopPeer, and Enroll Secret of shopPeerpw. Click Next. Set the Type for this identity as peer and select org1 from the affiliated organizations drop-down list. We will leave the Maximum enrollments and Add Attributes fields blank.
Use your CA to register repair shop identities (process is same as shown in gif above)
- Select the Repair Shop CA Certificate Authority that we created.
- First, we will register an admin for our Insurance Organization. Click on the Register User button. Give an Enroll ID of
repairShopAdmin, and Enroll Secret of repairShopAdminpw. Click Next. Set the Type for this identity as client and s