The best way to learn is by asking questions. We will proceed that way. There will be many useful links, in case you want to go through them in detail.
What is Insurance?
Insurance is basically an arrangement by which a company or the state undertakes to provide a guarantee of compensation for specified loss, damage, illness, or death in return for payment of a specified premium. The compensation process is initiated by a claim. We will deal with Property & Casualty(P&C) type of Insurance here.
What is the current flow process of an Insurance claim?
An Insuree may report a loss or a claim to a broker, and with the required information submits it to the Insuring authorities, namely the Insurer and if applicable, the Reinsurer . The claim submission is confirmed via a receipt to the Insuree. The Claims Agent may request for additional information for the claim, via an external source. After these steps, if all the conditions are satisfied, the claim is approved, and the payment is initiated via the Insurer’s Claim Agent.
What are the problems with the current situation?
Undesirable customer experience: To initiate a claim, the insuree must complete a complex questionnaire and maintain physical receipts of the costs incurred by the loss
Costly intermediaries: brokers act as intermediaries during processing, adding delays and costs to the submission
Fragmented data sources: Insurers must establish individual relationships with third-party data providers to get manual access to supporting asset, risk and loss data that may not be updated
Fraud prone: The loss assessment is completed on a per-insurer and per-loss basis with no information sharing between insurers, increasing the potential for fraud and manual rework
Manual claim processing: Loss adjusters are required to review claims and to:
- Ensure their completeness
- Request additional
- Information or use
- Supporting data sources
- Validate loss coverage
- Identify the scope of the
- liability
- Calculate the loss amount
Double Booking: Processing multiple claims for the same accident, adding redundancy.
What system do we propose?
We implement a blockchain based solution for the above problems, wherein the smart contract will be established in the network and will be applied for all the transactions applied or processed.
How does the system proposed fix the problems?
- When we talk about the architecture of the system, blockchain, all the properties are inherited. This means issues such as tampering of data, or node failures will not affect all the other nodes, ensuring safety and security.
- The claims processing will consist of either an application interface, or the use of smart assets for submitting claims. A simple implication of this is the elimination of the need of a broker, saving cost.
- The claim processing is automated completely, and hence there is no unnecessary delay, benefiting the users on both ends.
- The Insurer will seamlessly have access to historical claims and asset provenance, enabling better identification of suspicious behaviour, thus reducing fraudulent activities.
- Integrated data sources ensure the validity of data, thus minimising manual review.
- Payment process is even more simplified due to it being integrated.
- According to the smart contract logic, multiple claims cannot be added for the same accident, thus eliminating double booking.
- In the case of a DDoS attack, since the system is regularly updated with the latest block, accessing any of the active nodes means acquiring the latest data, thus effectively blocking DDoS - which is a highly-desirable trait for network security.
What are the steps of the proposed flow process of an Insurance claim?
The steps can be depicted as follows:
- The Insuree submits a claim via an interface, or perhaps using external sources or sensors, making the Claim application automated.
- The Insurance Policies are verified by a smart contract, and the feedback to the user is almost immediate.
- The secondary data sources are integrated into the network, and provide relevant information to the necessary entity
- Depending on the insurance policy, the smart contract can automate the liability calculation, in the case of a Reinsuring Entity.
- The Insuree finally makes a decision, and payment is initiated via a payment portal embedded in the network.
With what do we implement our solution?
We implement the above system using the Hyperledger Fabric’s chaincode interface, using Golang .
How do we acquire the skills to do so?
To get yourself familiarised with developing on the Hyperledger Fabric, refer to these docs and tutorials .
To understand the architecture in detail, refer to this article .
How do we configure our network?
For development’s sake, let us use 1 Orderer, 1 Organisation and 1 Peer belonging to that Organisation.
We name the channel as mychannel
, and the chaincode as mycc
Thus our config files should look as follows
docker-compose.yaml
crypto-config.yml
configtx.yaml
How do we start writing the chaincode?
Modularity is key. Hence the directory structure :
claim.go
handles all claim related operationsorganisation.go
handles all organisation related operationsuser.go
handles all user related operationsutils.go
contains utility functionserrorhandler.go
centralises error handlingpayments.go
handles all payment related actionsmain.go
is our main handler that contains the required API methods for Invoking or Querying
Users belong to organisations, and organisations comprise different roles.
How do we write the necessary functions?
There are three necessary parts for writing chaincode -
- Init - is called during chaincode instantiation to initialise any data.
- Invoke - is used to commit transactions to the ledger, can be compared to the POST method.
- Query - is used to query the ledger and mock an invoke function, and doesn’t write the transaction to the ledger. Can be compared to the GET method.
You can understand what they do in greater detail here
So main.go should look like this
We define a simple model for our user.
This is how user.go looks like
As you can observe from the above snippets, we can define methods for doing a myriad of stuff with our respective entities and claim handling. We implement policies according to the use case and embed them in our smart contract. For example, if you were to change the status of a claim, there has to be an authentication middleware endpoint that only lets users belonging to an endpoint.
What do GetState and PutState mean?
They are functions defined in the shim.ChaincodeStubInterface package, that let you get the data from the database and let you commit data to the database respectively.
What database is used to store the ledger transactions?
Hyperledger Fabric uses CouchDB , a key-value type database. Note that state is synonymous to database.
How do we start the network?
We write bash files that can execute all our commands with ease.
- Initiating and Generating Crypto material from
docker-compose.yaml
init.sh
generate.sh
- Starting the network
start.sh
How do we install and instantiate the chaincode on the network?
We use another bash script.
install.sh
How do we Invoke or Query a function in the chaincode?
We can test the scenario by using our cli
container mentioned in docker-compose.yml
. By issuing specific query or invoke commands, we can test the features we implement.
Example Usage:
We have to specify our function name as the first element in the array, and the rest of the arguments follow.
Going by the above mentioned addUser
example,
How do we verify the changes in state?
After you commit transactions, if you’re running the network in you local server, as is mentioned in our docker-compose.yaml
file above, the CouchDB UI interface will be present at the address
http://localhost:5984/_utils
. You can view all the changes to state here.
How do we scale the network?
We simply have to change the configuration files as mentioned above, to accommodate the different types of entities and organisations we will be dealing with. The application endpoint should interact with the network successfully.
What did we learn?
Literally the title itself. A lot more, if you’ve visited the links specified.
Do we want to learn more?
Let me know in the comments.