Building a (Re)insurance blockchain network with Hyperledger Composer

Simple blockchain definition

A blockchain is essentially a ledger of records, of digitale events, shared/distributed between many different parties. It can only be updated by consensus of a majority of the participants in the system. And, once created, information can never be altered. The blockchain contains a certain an verifiable record of every single transaction ever made.

Benefits

  • Single version of an asset, thanks to the sharing/distributed ledger. Theses assets are then wrapped in the form of smart contract. For example assets could be risk, technical or financial account, claim.
  • Decrease of times in the accounting and settlements
  • Improvement in the operational cost, as a lot of time is currently spent by organisations on reconciliation
  • Automation through smart policy
  • Efficient exchange of information
  • Reduced fraud loss

Use case

  • As a Reinsurance organization, I would like to see the finance related status of claims requested by my cedents
  • As a Cedent organization, i would like to see the real time status of every claims
Reinsurance Network Participants

Developer guide for creating a Hyperledger Composer solution for reinsurance

This guide will help you to build a Hyperledger Composer blockchain solution. You will be able to execute transactions against a real Hyperledger Fabric blockchain network for Reinsurance Claims that interacts with a blockchain network.

Participants/Assets interactions that we are about to build

Installing Hyperledger Composer

Creating the Reinsurance Claims Business Network Definition

The easiest way is to clone an existing sample business network. Open up a command prompt and clone the Composer sample networks GitHub repository from Hyperledger. For Linux, perform this as a non-root user.

> git clone https://github.com/hyperledger/composer-sample-networks.git

Then, make a copy of this directory in your project, called “reinsurance-network

> cp -r ./composer-sample-networks/packages/basic-sample-network/  ./reinsurance-network

You should now have a folder called reinsurance-network that we can start to modify. Using an Editor Code (like Visual Studio Code or Sublime Text), open the reinsurance-network folder. You should see the file layout in the explorer.

Updating the project configuration file

Defining the reinsurance claims Domain Model

We are going to replace the entire contents of the file ‘sample.cto’ with the simplistic reinsurance claims model to track the interactions between cedent and reinsurance on the blockchain:

The domain model defines two assets (Contrat, AvisSinistre) and two participants (“Cedante”, “Reassureur”) and a two transactions (“DeclarerSinistre”, “SouscrireContrat”) that is used to claims a sinister.

Finally rename the file ‘sample.cto’ to ‘reinsurance.cto

Reinsurance Composer model

Write Transaction Processor Functions (Claiming)

Open the file lib/sample.js. If a JavaScript function has the @transaction annotation, it will be automatically invoked when a transaction of the type defined by the @param annotation is submitted.

Now replace the contents of sample.js with the function below :

This onDeclarationSinistre function simply add the claim amount to the cedent, and substract it from the reinsurer based on an incoming claim transaction. It then persists the modified asset and participants back into the registry.

Save your changes to lib/reinsurance.js

Generate the Business Network Archive

> cd reinsurance-network
> npm install

You should see the following output:

> reinsurance-network@0.0.1 prepublish /home/user/reinsurance-network> mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/reinsurance-network.bna
Creating Business Network Archive
Looking for package.json of Business Network Definition in /home/user/reinsurance-networkFound:
Description: Reinsurance Trading network
Name: reinsurance-network
Identifier: reinsurance-network@0.0.1
Written Business Network Definition Archive file to ./dist/reinsurance-network.bna
Command completed successfully.
Command succeeded

The command has created a file called reinsurance-network.bna in the dist folder.

Import into Playground and Test

Locate the dist/reinsurance-network.bna file under your “reinsurance-network” folder and upload it, then press the “Deploy” button.

Node : You can also run a local Playground and import the model and add other participants like bellow :

Testing the reinsurance Business Network definition

Create one cedent participant (AGF) by clicking the “Cedante” registry and the Create New Participant button.

{
"$class": "reinsurance.claims.Cedante",
"id": "id :AGF",
"name": "AGF",
"solde": "1000"
}

Creating one reinsurance company

Create one “Reassurance” participant (for example CCR, Scor, or Swiss Re) by clicking the Reassurance registry and the Create New Participant button.

 {
"$class": "reinsurance.claims.Reassurance",
"id": "id :CCR",
"name": "CCR",
"solde": "1000"
}

Creating a claim

Create a new instance of a Claim by navigating to the “AvisSinistre” registry and then click the Create New Asset button.

{
"$class": "reinsurance.claims.AvisSinistre",
"id": "id :Sinistre1",
"name": "Sinistre Incendie",
"information": "Incendie immeuble 1930",
"montant": "40",
"sent": "false"
}

You should see the following content in the Playground

Transferring the claim from cedent to reinsurance compagny

Next, submit a “DeclarerSinistre” transaction by clicking the “Submit Transaction” button. This will send the claim from the cedent to the reinsurance :

{
"$class": "reinsurance.claims.DeclarerSinistre",
"avisSinistre": "resource:reinsurance.claims.AvisSinistre:id:Incendie1",
"cedante": "resource:reinsurance.claims.Cedante#id:AGF",
"reassureur": "resource:reinsurance.claims..Reassureur#id:CCR"
}

After processing, you should now see the transaction in the transaction registry:

As a result, the balance of the reinsurance and cedent should be updated in the Asset Registry like below :
Cedent balance : 1000 + 40 = 1040
Reinsurance balance : 1000–40 = 960

If you are locally runing the Hyperledger Fabric and an explorer tool, you could see the transaction status in real time like bellow:

In a coming article, we will generate a REST API to provide developers easier interaction with the blockchain :

Software Architect @ Object’ive — Blockchain enthusiast — https://twitter.com/fstepho

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store