• Stars
    star
    719
  • Rank 60,550 (Top 2 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sample insurance application using Hyperledger Fabric

WARNING: This repository is no longer maintained ⚠️

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

Workflow

  1. The blockchain operator creates a IBM Kubernetes Service cluster (32CPU, 32RAM, 3 workers recommended) and an IBM Blockchain Platform 2.0 service.
  2. 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.
  3. The Node.js application server uses the Fabric SDK to interact with the deployed network on IBM Blockchain Platform 2.0.
  4. The React UI uses the Node.js application API to interact and submit transactions to the network.
  5. 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)

  1. Create IBM Cloud services
  2. Build a network - Certificate Authority
  3. Build a network - Create MSP Definitions
  4. Build a network - Create Peers
  5. Build a network - Create Orderer
  6. Build a network - Create and Join Channel
  7. Deploy Insurance Smart Contract on the network
  8. Connect application to the network
  9. Enroll App Admin Identities
  10. 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 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 repairShopPeer, and Enroll Secret of repairShopPeerpw. 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 police shop identities (process is same as shown in gif above)

    • Select the Police 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 policeAdmin, and Enroll Secret of policeAdminpw. 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 policePeer, and Enroll Secret of policePeerpw. 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.

Step 3. Build a network - Create MSP Definitions

  • Create the insurance MSP definition

    • Navigate to the Organizations tab in the left navigation and click Create MSP definition.
    • Enter the MSP Display name as Insurance MSP and an MSP ID of insurancemsp.
    • Under Root Certificate Authority details, specify the peer CA that we created Insurance CA as the root CA for the organization.
    • Give the Enroll ID and Enroll secret for your organization admin, insuranceAdmin and insuranceAdminpw. Then, give the Identity name, Insurance Admin.
    • Click the Generate button to enroll this identity as the admin of your organization and export the identity to the wallet. Click Export to export the admin certificates to your file system. Finally click Create MSP definition.


  • Create the shop MSP definition (same process as shown in gif above)

    • Navigate to the Organizations tab in the left navigation and click Create MSP definition.
    • Enter the MSP Display name as Shop MSP and an MSP ID of shopmsp.
    • Under Root Certificate Authority details, specify the peer CA that we created Shop CA as the root CA for the organization.
    • Give the Enroll ID and Enroll secret for your organization admin, shopAdmin and shopAdminpw. Then, give the Identity name, Shop Admin.
    • Click the Generate button to enroll this identity as the admin of your organization and export the identity to the wallet. Click Export to export the admin certificates to your file system. Finally click Create MSP definition.
  • Create the repair shop MSP definition (same process as shown in gif above)

    • Navigate to the Organizations tab in the left navigation and click Create MSP definition.
    • Enter the MSP Display name as Repair Shop MSP and an MSP ID of repairshopmsp.
    • Under Root Certificate Authority details, specify the peer CA that we created Repair Shop CA as the root CA for the organization.
    • Give the Enroll ID and Enroll secret for your organization admin, repairShopAdmin and repairShopAdminpw. Then, give the Identity name, Repair Shop Admin.
    • Click the Generate button to enroll this identity as the admin of your organization and export the identity to the wallet. Click Export to export the admin certificates to your file system. Finally click Create MSP definition.
  • Create the police MSP definition (same process as shown in gif above)

    • Navigate to the Organizations tab in the left navigation and click Create MSP definition.
    • Enter the MSP Display name as Police MSP and an MSP ID of policemsp.
    • Under Root Certificate Authority details, specify the peer CA that we created Police CA as the root CA for the organization.
    • Give the Enroll ID and Enroll secret for your organization admin, policeAdmin and policeAdminpw. Then, give the Identity name, Police Admin.
    • Click the Generate button to enroll this identity as the admin of your organization and export the identity to the wallet. Click Export to export the admin certificates to your file system. Finally click Create MSP definition.

Step 4. Build a network - Create Peers

  • Create an insurance peer
    • On the Nodes page, click Add peer.
    • Click IBM Cloud under Create a new peer and Next.
    • Give your peer a Display name of Insurance Peer.
    • On the next screen, select Insurance CA as your Certificate Authority. Then, give the Enroll ID and Enroll secret for the peer identity that you created for your peer, insurancePeer, and insurancePeerpw. Then, select the Administrator Certificate (from MSP), Insurance MSP, from the drop-down list and click Next.
    • Give the TLS Enroll ID, admin, and TLS Enroll secret, adminpw, the same values are the Enroll ID and Enroll secret that you gave when creating the CA. Leave the TLS CSR hostname blank.
    • The last side panel will ask you to Associate an identity and make it the admin of your peer. Select your peer admin identity Insurance Admin.
    • Review the summary and click Submit.


  • Create a shop peer (same process as shown in gif above)

    • On the Nodes page, click Add peer.
    • Click IBM Cloud under Create a new peer and Next.
    • Give your peer a Display name of Shop Peer.
    • On the next screen, select Shop CA as your Certificate Authority. Then, give the Enroll ID and Enroll secret for the peer identity that you created for your peer, shopPeer, and shopPeerpw. Then, select the Administrator Certificate (from MSP), Shop MSP, from the drop-down list and click Next.
    • Give the TLS Enroll ID, admin, and TLS Enroll secret, adminpw, the same values are the Enroll ID and Enroll secret that you gave when creating the CA. Leave the TLS CSR hostname blank.
    • The last side panel will ask you to Associate an identity and make it the admin of your peer. Select your peer admin identity Shop Admin.
    • Review the summary and click Submit.
  • Create a repair shop peer (same process as shown in gif above)

    • On the Nodes page, click Add peer.
    • Click IBM Cloud under Create a new peer and Next.
    • Give your peer a Display name of Repair Shop Peer.
    • On the next screen, select Repair Shop CA as your Certificate Authority. Then, give the Enroll ID and Enroll secret for the peer identity that you created for your peer, repairShopPeer, and repairShopPeerpw. Then, select the Administrator Certificate (from MSP), Repair Shop MSP, from the drop-down list and click Next.
    • Give the TLS Enroll ID, admin, and TLS Enroll secret, adminpw, the same values are the Enroll ID and Enroll secret that you gave when creating the CA. Leave the TLS CSR hostname blank.
    • The last side panel will ask you to Associate an identity and make it the admin of your peer. Select your peer admin identity Repair Shop Admin.
    • Review the summary and click Submit.
  • Create a police peer (same process as shown in gif above)

    • On the Nodes page, click Add peer.
    • Click IBM Cloud under Create a new peer and Next.
    • Give your peer a Display name of Police Peer.
    • On the next screen, select Police CA as your Certificate Authority. Then, give the Enroll ID and Enroll secret for the peer identity that you created for your peer, policePeer, and policePeerpw. Then, select the Administrator Certificate (from MSP), Police MSP, from the drop-down list and click Next.
    • Give the TLS Enroll ID, admin, and TLS Enroll secret, adminpw, the same values are the Enroll ID and Enroll secret that you gave when creating the CA. Leave the TLS CSR hostname blank.
    • The last side panel will ask you to Associate an identity and make it the admin of your peer. Select your peer admin identity Police Admin.
    • Review the summary and click Submit.

Step 5. Build a network - Create Orderer

  • Create your orderer organization CA

    • Click Add Certificate Authority.
    • Click IBM Cloud under Create Certificate Authority and Next.
    • Give it a unique Display name of Orderer CA.
    • Specify an Admin ID of admin and Admin Secret of adminpw.


  • Use your CA to register orderer and orderer admin identities (shown in gif above)

    • In the Nodes tab, select the Orderer CA Certificate Authority that we created.
    • First, we will register an admin for our organization. Click on the Register User button. Give an Enroll ID of ordereradmin, and Enroll Secret of ordereradminpw. 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 orderer. Click on the Register User button. Give an Enroll ID of orderer1, and Enroll Secret of orderer1pw. 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.
  • Create the orderer organization MSP definition

    • Navigate to the Organizations tab in the left navigation and click Create MSP definition.
    • Enter the MSP Display name as Orderer MSP and an MSP ID of orderermsp.
    • Under Root Certificate Authority details, specify the peer CA that we created Orderer CA as the root CA for the organization.
    • Give the Enroll ID and Enroll secret for your organization admin, ordereradmin and ordereradminpw. Then, give the Identity name, Orderer Admin.
    • Click the Generate button to enroll this identity as the admin of your organization and export the identity to the wallet. Click Export to export the admin certificates to your file system. Finally click Create MSP definition.


  • Create an orderer

    • On the Nodes page, click Add orderer.
    • Click IBM Cloud and proceed with Next.
    • Give your peer a Display name of Orderer.
    • On the next screen, select Orderer CA as your Certificate Authority. Then, give the Enroll ID and Enroll secret for the peer identity that you created for your orderer, orderer1, and orderer1pw. Then, select the Administrator Certificate (from MSP), Orderer MSP, from the drop-down list and click Next.
    • Give the TLS Enroll ID, admin, and TLS Enroll secret, adminpw, the same values are the Enroll ID and Enroll secret that you gave when creating the CA. Leave the TLS CSR hostname blank.
    • The last side panel will ask to Associate an identity and make it the admin of your peer. Select your peer admin identity Orderer Admin.
    • Review the summary and click Submit.


  • Add organizations as Consortium Member on the orderer to transact

    • Navigate to the Nodes tab, and click on the Orderer that we created.
    • Under Consortium Members, click Add organization.
    • From the drop-down list, select Insurance MSP.
    • Click Submit.
    • Repeat the same steps, but add Shop MSP, Repair Shop MSP, and Police MSP as well.


Step 6. Build a network - Create and Join Channel

  • Create the channel

    • Navigate to the Channels tab in the left navigation.
    • Click Create channel.
    • Give the channel a name, mychannel.
    • Select the orderer you created, Orderer from the orderers drop-down list.
    • Select the MSP identifying the organization of the channel creator from the drop-down list. This should be Insurance MSP (insurancemsp).
    • Associate available identity as Insurance Admin.
    • Click Add next to the insurance organization. Make the insurance organization an Operator.
    • Click Add next to the shop organization. Make the shop organization an Operator.
    • Click Add next to the repair shop organization. Make the repair shop organization an Operator.
    • Click Add next to the police organization. Make the insurance organpoliceization an Operator.
    • Click Create.


  • Join your peer to the channel

    • Click Join channel to launch the side panels.
    • Select your Orderer and click Next.
    • Enter the name of the channel you just created. mychannel and click Next.
    • Select which peers you want to join the channel, click Insurance Peer, Shop Peer, Repair Shop Peer, and Police Peer.
    • Click Submit.


  • Add anchor peers to the channel

    • In order to communicate between organizations, we need to enroll anchor peers.
    • From the channels tab, click on the channel you have created, mychannel.
    • From the channel overview page, click on channel details. Scroll all the way down until you see Anchor peers.
    • Click Add anchor peer and add the Insurance, Police, Repair Shop, and Shop peers.
    • Select which peers you want to join the channel, click Insurance Peer, Shop Peer, Repair Shop Peer, and Police Peer.
    • Click Add anchor peer.
    • If all went well, your channel Anchor peers should look like below:


Step 7. Deploy Insurance Smart Contract on the network

  • Install a smart contract

  • Clone the repository:
    git clone https://github.com/IBM/build-blockchain-insurance-app
    • Click the Smart contracts tab to install the smart contract.
    • Click Install smart contract to upload the insurance smart contract package file.
    • Click on Add file and find your packaged smart contract. It is the file in the build-blockchain-insurance-app/chaincodePackage directory.
    • Select all peers - we need to install the contract on each peer.
    • Once the contract is uploaded, click Install.


  • Instantiate smart contract

    • On the smart contracts tab, find the smart contract from the list installed on your peers and click Instantiate from the overflow menu on the right side of the row.
    • On the side panel that opens, select the channel, mychannel to instantiate the smart contract on. Click Next.
    • Select the organization members to be included in the policy, insurancemsp, shopmsp, repairshopmsp, policemsp. Click Next.
    • Give Function name of Init and leave Arguments blank.
    • Click Instantiate.


Step 8. Connect application to the network

  • Connect with sdk through connection profile

    • Under the Instantiated Smart Contract, click on Connect with SDK from the overflow menu on the right side of the row.
    • Choose from the dropdown for MSP for connection, insurancemsp.
    • Choose from Certificate Authority dropdown, Insurance CA.
    • Download the connection profile by scrolling down and clicking Download Connection Profile. This will download the connection json which we will use soon to establish connection.
    • You can click Close once the download completes.


  • Create insurance application admin

    • Go to the Nodes tab on the left bar, and under Certificate Authorities, choose your Insurance CA.
    • Click on Register user.
    • Give an Enroll ID and Enroll Secret to administer your application users, insuranceApp-admin and insuranceApp-adminpw.
    • Choose client as Type.
    • You can leave the Use root affiliation box checked.
    • You can leave the Maximum enrollments blank.
    • Under Attributes, click on Add attribute. Give attribute as hf.Registrar.Roles = *. This will allow this identity to act as registrar and issues identities for our app. Click Add-attribute.
    • Click Register.


  • Create shop application admin (same process as shown above in the gif)

    • Go to the Nodes tab on the left bar, and under Certificate Authorities, choose your Shop CA.
    • Click on Register user.
    • Give an Enroll ID and Enroll Secret to administer your application users, shopApp-admin and shopApp-adminpw.
    • Choose client as Type.
    • You can leave the Use root affiliation box checked.
    • You can leave the Maximum enrollments blank.
    • Under Attributes, click on Add attribute. Give attribute as hf.Registrar.Roles = *. This will allow this identity to act as registrar and issues identities for our app. Click Add-attribute.
    • Click Register.
  • Create repair shop application admin (same process as shown above in the gif)

    • Go to the Nodes tab on the left bar, and under Certificate Authorities, choose your Repair Shop CA.
    • Click on Register user.
    • Give an Enroll ID and Enroll Secret to administer your application users, repairShopApp-admin and repairShopApp-adminpw.
    • Choose client as Type.
    • You can leave the Use root affiliation box checked.
    • You can leave the Maximum enrollments blank.
    • Under Attributes, click on Add attribute. Give attribute as hf.Registrar.Roles = *. This will allow this identity to act as registrar and issues identities for our app. Click Add-attribute.
    • Click Register.
  • Create police application admin (same process as shown above in the gif)

    • Go to the Nodes tab on the left bar, and under Certificate Authorities, choose your Police CA.
    • Click on Register user.
    • Give an Enroll ID and Enroll Secret to administer your application users, policeApp-admin and policeApp-adminpw.
    • Choose client as Type.
    • You can leave the Use root affiliation box checked.
    • You can leave the Maximum enrollments blank.
    • Under Attributes, click on Add attribute. Give attribute as hf.Registrar.Roles = *. This will allow this identity to act as registrar and issues identities for our app. Click Add-attribute.
    • Click Register.

Update application connection

  • Copy the connection profile you downloaded into the web/www/blockchain directory.
  • Copy and paste everything in the connection profile, and overwrite the ibpConnection.json.

Step 9. Enroll App Admin Identities

  • Enroll insurnaceApp-admin

    • First, navigate to the web/www/blockchain directory.

      cd web/www/blockchain/
    • Open the config.json file, and update the caName with the URL of the insurance certificate authority from your ibpConnection.json file. Save the file.

    • Run the enrollAdmin.js script

      node enrollAdmin.js
    • You should see the following in the terminal:

      msg: Successfully enrolled admin user insuranceApp-admin and imported it into the wallet

  • Enroll shopApp-admin
    • First, change the appAdmin, appAdminSecret, and caName properties in your config.json file, so that it looks something like this (your caName should be different than mine):

      {
          "connection_file": "ibpConnection.json",
          "appAdmin": "shopApp-admin",
          "appAdminSecret": "shopApp-adminpw",
          "orgMSPID": "shopmsp",
          "caName": "https://fa707c454921423c80ec3c3c38d7545c-caf2e287.horeainsurancetest.us-south.containers.appdomain.cloud:7054",
          "userName": "shopUser",
          "gatewayDiscovery": { "enabled": true, "asLocalhost": false }
      }
    • To find the other CA urls, you will need to click on the Nodes tab in IBM Blockchain Platform, then on the Shop CA, and on the settings cog icon at the top of the page. That will take you to the certificate authority settings, as shown in the picture below, and you can copy that endpoint URL into your config.json caName field.


  • Run the enrollAdmin.js script

    node enrollAdmin.js
  • You should see the following in the terminal:

    msg: Successfully enrolled admin user shopApp-admin and imported it into the wallet
  • Enroll repairShopApp-admin (same process as shown in gif above)

    • First, change the appAdmin, appAdminSecret, and caName properties in your config.json file, so that it looks something like this (your caName should be different than mine):

      {
          "connection_file": "ibpConnection.json",
          "appAdmin": "repairShopApp-admin",
          "appAdminSecret": "repairShopApp-adminpw",
          "orgMSPID": "repairshopmsp",
          "caName": "https://fa707c454921423c80ec3c3c38d7545c-caf2e287.horeainsurancetest.us-south.containers.appdomain.cloud:7054",
          "userName": "repairUser",
          "gatewayDiscovery": { "enabled": true, "asLocalhost": false }
      }
    • Run the enrollAdmin.js script

      node enrollAdmin.js
    • You should see the following in the terminal:

      msg: Successfully enrolled admin user repairShopApp-admin and imported it into the wallet
  • Enroll policeApp-admin (same process as shown in gif above)

    • First, change the appAdmin, appAdminSecret, and caName properties in your config.json file, so that it looks something like this (your caName should be different than mine):

      {
          "connection_file": "ibpConnection.json",
          "appAdmin": "policeApp-admin",
          "appAdminSecret": "policeApp-adminpw",
          "orgMSPID": "policemsp",
          "caName": "https://fa707c454921423c80ec3c3c38d7545c-caf2e287.horeainsurancetest.us-south.containers.appdomain.cloud:7054",
          "userName": "policeUser",
          "gatewayDiscovery": { "enabled": true, "asLocalhost": false }
      }
    • Run the enrollAdmin.js script

      node enrollAdmin.js
    • You should see the following in the terminal:

      msg: Successfully enrolled admin user policeApp-admin and imported it into the wallet

Step 10. Run the application

Navigate to the directory blockchain directory which contains the config.js file:

cd build-blockchain-insurance-app/web/www/blockchain/

In the editor of choice, change line 8 of the config.js file to isCloud: true as shown in the image below:

Is Cloud

If you are using Mac, save the changes. Otherwise, if you are using an Ubuntu system, change line 9 of config.js file to isUbuntu: true as shown in the image below:

Is Ubuntu

Next, from the blockchain directory navigate to the root project directory:

blockchain$ cd ../../../
build-blockchain-insurance-app$   

Login using your docker hub credentials.

docker login

Run the build script to download and create docker images for the orderer, insurance-peer, police-peer, shop-peer, repairshop-peer, web application and certificate authorities for each peer. This will run for a few minutes.

For Mac user:

cd build-blockchain-insurance-app
./build_mac.sh

For Ubuntu user Make sure isUbuntu:true is saved in the line 9 of config.js:

cd build-blockchain-insurance-app
./build_ubuntu.sh

You should see the following output on console:

Creating repairshop-ca ...
Creating insurance-ca ...
Creating shop-ca ...
Creating police-ca ...
Creating orderer0 ...
Creating repairshop-ca
Creating insurance-ca
Creating police-ca
Creating shop-ca
Creating orderer0 ... done
Creating insurance-peer ...
Creating insurance-peer ... done
Creating shop-peer ...
Creating shop-peer ... done
Creating repairshop-peer ...
Creating repairshop-peer ... done
Creating web ...
Creating police-peer ...
Creating web
Creating police-peer ... done


Wait for few minutes for application to install and instantiate the chaincode on network

Check the status of installation using command:

docker logs web

On completion, you should see the following output on console:

> [email protected] serve /app
> cross-env NODE_ENV=production&&node ./bin/server

/app/app/static/js
Server running on port: 3000
Default channel not found, attempting creation...
Successfully created a new default channel.
Joining peers to the default channel.
Chaincode is not installed, attempting installation...
Base container image present.
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
Successfully installed chaincode on the default channel.
Successfully instantiated chaincode on all peers.

Use the link http://localhost:3000 to load the web application in browser.

The home page shows the participants (Peers) in the network. You can see that there is an Insurance, Repair Shop, Police and Shop Peer implemented. They are the participants of the network.

Blockchain Insurance

Imagine being a consumer (hereinafter called “Biker”) that wants to buy a phone, bike or Ski. By clicking on the “Go to the shop” section, you will be redirected to the shop (shop peer) that offers you the following products.

Customer Shopping

You can see the three products offered by the shop(s) now. In addition, you have insurance contracts available for them. In our scenario, you are an outdoor sport enthusiast who wants to buy a new Bike. Therefore, you’ll click on the Bike Shop section.

Shopping

In this section, you are viewing the different bikes available in the store. You can select within four different Bikes. By clicking on next you’ll be forwarded to the next page which will ask for the customer’s personal data.

Bike Shop

You have the choice between different insurance contracts that feature different coverage as well as terms and conditions. You are required to type-in your personal data and select a start and end date of the contract. Since there is a trend of short-term or event-driven contracts in the insurance industry you have the chance to select the duration of the contract on a daily basis. The daily price of the insurance contract is being calculated by a formula that had been defined in the chaincode. By clicking on next you will be forwarded to a screen that summarizes your purchase and shows you the total sum.

Bike Insurance

The application will show you the total sum of your purchase. By clicking on “order” you agree to the terms and conditions and close the deal (signing of the contract). In addition, you’ll receive a unique username and password. The login credentials will be used once you file a claim. A block is being written to the Blockchain.

note You can see the block by clicking on the black arrow on the bottom-right.

At this point, you should be able to go into your IBM Blockchain Platform console, click on the channels, and then be able to see the contract_create block being added.


For additional steps on how to file more claims, and use the rest of the application, please go here.

Congratulations! You've successfully connection your React app to the IBM Blockchain Platform! Now each time you submit transactions with the UI, they will be logged by the blockchain service.

Additional resources

Following is a list of additional blockchain resources:

Troubleshooting

  • Run clean.sh to remove the docker images and containers for the insurance network.
./clean.sh

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

More Repositories

1

sarama

Sarama is a Go library for Apache Kafka.
Go
10,858
star
2

plex

The package of IBM’s typeface, IBM Plex.
CSS
9,297
star
3

css-gridish

Automatically build your grid design’s CSS Grid code, CSS Flexbox fallback code, Sketch artboards, and Chrome extension.
CSS
2,253
star
4

openapi-to-graphql

Translate APIs described by OpenAPI Specifications (OAS) into GraphQL
TypeScript
1,594
star
5

Project_CodeNet

This repository is to support contributions for tools for the Project CodeNet dataset hosted in DAX
Python
1,485
star
6

fp-go

functional programming library for golang
Go
1,480
star
7

pytorch-seq2seq

An open source framework for seq2seq models in PyTorch.
Python
1,431
star
8

fhe-toolkit-linux

IBM Fully Homomorphic Encryption Toolkit For Linux. This toolkit is a Linux based Docker container that demonstrates computing on encrypted data without decrypting it! The toolkit ships with two demos including a fully encrypted Machine Learning inference with a Neural Network and a Privacy-Preserving key-value search.
C++
1,427
star
9

ibm.github.io

IBM Open Source at GitHub
JavaScript
1,106
star
10

MicroscoPy

An open-source, motorized, and modular microscope built using LEGO bricks, Arduino, Raspberry Pi and 3D printing.
Python
1,102
star
11

Dromedary

Dromedary: towards helpful, ethical and reliable LLMs.
Python
1,059
star
12

MAX-Image-Resolution-Enhancer

Upscale an image by a factor of 4, while generating photo-realistic details.
Python
863
star
13

elasticsearch-spark-recommender

Use Jupyter Notebooks to demonstrate how to build a Recommender with Apache Spark & Elasticsearch
Jupyter Notebook
806
star
14

differential-privacy-library

Diffprivlib: The IBM Differential Privacy Library
Python
774
star
15

FfDL

Fabric for Deep Learning (FfDL, pronounced fiddle) is a Deep Learning Platform offering TensorFlow, Caffe, PyTorch etc. as a Service on Kubernetes
Go
676
star
16

spring-boot-microservices-on-kubernetes

In this code we demonstrate how a simple Spring Boot application can be deployed on top of Kubernetes. This application, Office Space, mimicks the fictitious app idea from Michael Bolton in the movie "Office Space".
JavaScript
548
star
17

cloud-native-starter

Cloud Native Starter for Java/Jakarta EE based Microservices on Kubernetes and Istio
Shell
517
star
18

federated-learning-lib

A library for federated learning (a distributed machine learning process) in an enterprise environment.
Python
480
star
19

nicedoc.io

pretty README as service.
JavaScript
473
star
20

clai

Command Line Artificial Intelligence or CLAI is an open-sourced project from IBM Research aimed to bring the power of AI to the command line interface.
Python
466
star
21

import-tracker

Python utility for tracking third party dependencies within a library
Python
458
star
22

mac-ibm-enrollment-app

The Mac@IBM enrollment app makes setting up macOS with Jamf Pro more intuitive for users and easier for IT. The application offers IT admins the ability to gather additional information about their users during setup, allows users to customize their enrollment by selecting apps or bundles of apps to install during setup, and provides users with next steps when enrollment is complete.
Swift
454
star
23

mobx-react-router

Keep your MobX state in sync with react-router
JavaScript
437
star
24

openapi-validator

Configurable and extensible validator/linter for OpenAPI documents
JavaScript
429
star
25

EvolveGCN

Code for EvolveGCN: Evolving Graph Convolutional Networks for Dynamic Graphs
Python
384
star
26

fhe-toolkit-macos

IBM Homomorphic Encryption Toolkit For MacOS
C++
356
star
27

AutoMLPipeline.jl

A package that makes it trivial to create and evaluate machine learning pipeline architectures.
HTML
345
star
28

graphql-query-generator

Randomly generates GraphQL queries from a GraphQL schema
TypeScript
334
star
29

portieris

A Kubernetes Admission Controller for verifying image trust.
Go
329
star
30

BluePic

WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode.
Swift
325
star
31

FedMA

Code for Federated Learning with Matched Averaging, ICLR 2020.
Python
320
star
32

lale

Library for Semi-Automated Data Science
Python
320
star
33

powerai-counting-cars

Run a Jupyter Notebook to detect, track, and count cars in a video using Maximo Visual Insights (formerly PowerAI Vision) and OpenCV
Jupyter Notebook
317
star
34

evote

A voting application that leverages Hyperledger Fabric and the IBM Blockchain Platform to record and tally ballots.
JavaScript
316
star
35

aihwkit

IBM Analog Hardware Acceleration Kit
Jupyter Notebook
314
star
36

zshot

Zero and Few shot named entity & relationships recognition
Python
308
star
37

blockchain-network-on-kubernetes

Demonstrates the steps involved in setting up your business network on Hyperledger Fabric using Kubernetes APIs on IBM Cloud Kubernetes Service.
Shell
305
star
38

IBM-Z-zOS

The helpful and handy location for finding and sharing z/OS files, which are not included in the product.
REXX
296
star
39

charts

The IBM/charts repository provides helm charts for IBM and Third Party middleware.
Smarty
295
star
40

TabFormer

Code & Data for "Tabular Transformers for Modeling Multivariate Time Series" (ICASSP, 2021)
Python
295
star
41

blockchain-application-using-fabric-java-sdk

Create and Deploy a Blockchain Network using Hyperledger Fabric SDK Java
Java
292
star
42

mac-ibm-notifications

macOS agent used to display custom notifications and alerts to the end user.
Swift
289
star
43

MAX-Object-Detector

Localize and identify multiple objects in a single image.
Python
286
star
44

design-kit

The IBM Design kit is a collection of tools aimed to help you design and prototype experiences faster, with confidence and thoughtfulness. This kit is based on the IBM Design System. Also, you may use this documentation to create add-on libraries to the IBM Design System or submit bugs to the current system.
272
star
45

AccDNN

A compiler from AI model to RTL (Verilog) accelerator in FPGA hardware with auto design space exploration.
Verilog
270
star
46

deploy-ibm-cloud-private

Instructions and Code required to install IBM Cloud Private
HCL
263
star
47

vue-a11y-calendar

Accessible, internationalized Vue calendar
JavaScript
253
star
48

audit-ci

Audit NPM, Yarn, and PNPM dependencies in continuous integration environments, preventing integration if vulnerabilities are found at or above a configurable threshold while ignoring allowlisted advisories
TypeScript
253
star
49

watson-banking-chatbot

A chatbot for banking that uses the Watson Assistant, Discovery, Natural Language Understanding and Tone Analyzer services.
JavaScript
250
star
50

UQ360

Uncertainty Quantification 360 (UQ360) is an extensible open-source toolkit that can help you estimate, communicate and use uncertainty in machine learning model predictions.
Python
249
star
51

Kubernetes-container-service-GitLab-sample

This code shows how a common multi-component GitLab can be deployed on Kubernetes cluster. Each component (NGINX, Ruby on Rails, Redis, PostgreSQL, and more) runs in a separate container or group of containers.
Shell
243
star
52

tensorflow-hangul-recognition

Handwritten Korean Character Recognition with TensorFlow and Android
Python
232
star
53

transition-amr-parser

SoTA Abstract Meaning Representation (AMR) parsing with word-node alignments in Pytorch. Includes checkpoints and other tools such as statistical significance Smatch.
Python
229
star
54

BlockchainNetwork-CompositeJourney

Part 1 in a series of patterns showing the building blocks of a Blockchain application
Shell
227
star
55

pytorchpipe

PyTorchPipe (PTP) is a component-oriented framework for rapid prototyping and training of computational pipelines combining vision and language
Python
223
star
56

Graph2Seq

Graph2Seq is a simple code for building a graph-encoder and sequence-decoder for NLP and other AI/ML/DL tasks.
Python
219
star
57

LNN

A `Neural = Symbolic` framework for sound and complete weighted real-value logic
Python
214
star
58

Scalable-WordPress-deployment-on-Kubernetes

This code showcases the full power of Kubernetes clusters and shows how can we deploy the world's most popular website framework on top of world's most popular container orchestration platform.
Shell
214
star
59

janusgraph-utils

Develop a graph database app using JanusGraph
Java
204
star
60

ModuleFormer

ModuleFormer is a MoE-based architecture that includes two different types of experts: stick-breaking attention heads and feedforward experts. We released a collection of ModuleFormer-based Language Models (MoLM) ranging in scale from 4 billion to 8 billion parameters.
Python
203
star
61

ibm-generative-ai

IBM-Generative-AI is a Python library built on IBM's large language model REST interface to seamlessly integrate and extend this service in Python programs.
Python
202
star
62

tensorflow-large-model-support

Large Model Support in Tensorflow
199
star
63

Scalable-Cassandra-deployment-on-Kubernetes

In this code we provide a full roadmap the deployment of a multi-node scalable Cassandra cluster on Kubernetes. Cassandra understands that it is running within a cluster manager, and uses this cluster management infrastructure to help implement the application. Kubernetes concepts like Replication Controller, StatefulSets etc. are leveraged to deploy either non-persistent or persistent Cassandra clusters on Kubernetes cluster.
Shell
195
star
64

adaptive-federated-learning

Code for paper "Adaptive Federated Learning in Resource Constrained Edge Computing Systems"
Python
193
star
65

action-recognition-pytorch

This is the pytorch implementation of some representative action recognition approaches including I3D, S3D, TSN and TAM.
Python
193
star
66

gantt-chart

IBM Gantt Chart Component, integrable in Vanilla, jQuery, or React Framework.
JavaScript
193
star
67

api-samples

Samples code that uses QRadar API's
Python
192
star
68

cdfsl-benchmark

(ECCV 2020) Cross-Domain Few-Shot Learning Benchmarking System
Python
190
star
69

kube101

Kubernetes 101 workshop (https://ibm.github.io/kube101/)
Shell
184
star
70

CrossViT

Official implementation of CrossViT. https://arxiv.org/abs/2103.14899
Python
180
star
71

browser-functions

A lightweight serverless platform that uses Web Browsers as execution engines
JavaScript
180
star
72

pwa-lit-template

A template for building Progressive Web Applications using Lit and Vaadin Router.
TypeScript
176
star
73

rl-testbed-for-energyplus

Reinforcement Learning Testbed for Power Consumption Optimization using EnergyPlus
Python
170
star
74

AMLSim

The AMLSim project is intended to provide a multi-agent based simulator that generates synthetic banking transaction data together with a set of known money laundering patterns - mainly for the purpose of testing machine learning models and graph algorithms. We welcome you to enhance this effort since the data set related to money laundering is critical to advance detection capabilities of money laundering activities.
Python
170
star
75

socket-io

A Socket.IO client for C#
C#
169
star
76

tfjs-web-app

A TensorFlow.js Progressive Web App for Offline Visual Recognition
JavaScript
164
star
77

molformer

Repository for MolFormer
Jupyter Notebook
163
star
78

spark-tpc-ds-performance-test

Use the TPC-DS benchmark to test Spark SQL performance
TSQL
160
star
79

watson-online-store

Learn how to use Watson Assistant and Watson Discovery. This application demonstrates a simple abstraction of a chatbot interacting with a Cloudant NoSQL database, using a Slack UI.
HTML
156
star
80

istio101

Istio 101 workshop (https://ibm.github.io/istio101/)
Shell
154
star
81

Medical-Blockchain

A healthcare data management platform built on blockchain that stores medical data off-chain
Vue
150
star
82

watson-assistant-slots-intro

A Chatbot for ordering a pizza that demonstrates how using the IBM Watson Assistant Slots feature, one can fill out an order, form, or profile.
JavaScript
143
star
83

tsfm

Foundation Models for Time Series
Jupyter Notebook
143
star
84

simulai

A toolkit with data-driven pipelines for physics-informed machine learning.
Python
142
star
85

etcd-java

Alternative etcd3 java client
Java
141
star
86

deploy-react-kubernetes

Built for developers who are interested in learning how to deploy a React application on Kubernetes, this pattern uses the React and Redux framework and calls the OMDb API to look up movie information based on user input. This pattern can be built and run on both Docker and Kubernetes.
JavaScript
139
star
87

innovate-digital-bank

This repository contains instructions to build a digital bank composed of a set of microservices that communicate with each other. Using Nodejs, Express, MongoDB and deployed to a Kubernetes cluster on IBM Cloud.
JavaScript
137
star
88

ipfs-social-proof

IPFS Social Proof: A decentralized identity and social proof system
JavaScript
135
star
89

KubeflowDojo

Repository to hold code, instructions, demos and pointers to presentation assets for Kubeflow Dojo
Jupyter Notebook
132
star
90

probabilistic-federated-neural-matching

Bayesian Nonparametric Federated Learning of Neural Networks
Python
132
star
91

fhe-toolkit-ios

IBM Fully Homomorphic Encryption Toolkit For iOS
C++
131
star
92

pytorch-large-model-support

Large Model Support in PyTorch
130
star
93

taxinomitis

Source code for Machine Learning for Kids site
JavaScript
127
star
94

Decentralized-Energy-Composer

WARNING: This repository is no longer maintained ⚠️ We are no longer showing the Hyperledger Composer Service.
TypeScript
127
star
95

quantum-careers

Learn about career opportunities with IBM Quantum.
126
star
96

cloud-pak

IBM Cloud Paks are enterprise-grade containerized software by combining container images with enterprise capabilities for deployment in production use cases with integrations for management and lifecycle operations. Features such as pre-configured deployments based on product expertise, rolling upgrades, and management of production workloads.
Shell
126
star
97

build-knowledge-base-with-domain-specific-documents

Create a knowledge base using domain specific documents and the mammoth python library
Jupyter Notebook
125
star
98

japan-technology

IBM Related Japanese technical documents - Code Patterns, Learning Path, Tutorials, etc.
Jupyter Notebook
125
star
99

DiffuseKronA

DiffuseKronA: A Parameter Efficient Fine-tuning Method for Personalized Diffusion Models
125
star
100

compliance-trestle

An opinionated tooling platform for managing compliance as code, using continuous integration and NIST's OSCAL standard.
Python
124
star