Building a reinsurance 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.


Some of the benefits that a blockchain platform could provide in a reinsurance network are :

  • 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

The use case we are going to build is a claim processing for a Reinsurance Organization.

  • 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 was written with the latest Hyperledger Composer on Ubuntu Linux running with Hyperledger Fabric v1.0. It was written based on the hyperledger official documentation and adapted for reinsurance domain.

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

Follow this Development Environment Install guide — As well as installing Composer, it has instructions to quickly build a Hyperledger Fabric blockchain environment (using Docker containers) which we will use on in this guide.

Creating the Reinsurance Claims Business Network Definition

The key concept for Composer is the business network definition (BND). It defines the data model, business (and transaction) logic and access control rules for the blockchain solution. It executes on Hyperledger Fabric. To create a business network definition, we need to create the project structure on disk.

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

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

The metadata (name, version, description etc) for the business network definition is stored in the package.json file. Edit this file to change the name to ‘reinsurance-network’, the description to “Reinsurance Claims Network” and modify the prepublish script to change the name of the business network archive to ‘reinsurance-network.bna’.

Defining the reinsurance claims Domain Model

Open the file models/sample.cto and inspect the contents. This is the domain model for the business network definition. It defines the structure (schema) for the assets, transaction and participants in the business network.

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)

Now that the reinsurance domain model has been defined, we can write the business logic for the business network definition. Written in javascript, these functions are automatically executed when a transaction is submitted for processing.

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

We can now generate a Business Network Archive (BNA) file for our reinsurance business network definition. Go back to the terminal and type:

> 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

In a browser, navigate to the online Bluemix Composer Playground and import the generated BNA file into the Playground application using the “Import/Replace” button.

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

Creating one cedent company

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

"$class": "",
"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": "",
"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": "",
"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": "",
"avisSinistre": "",
"cedante": "",
"reassureur": ""

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 :

You can follow me on my twitter for cryptocurrency news :

You can follow me on my github for cryptocurrency development ideas :