Inspiration
Insurance is a world set to be disrupted by Distributed Ledger Technology. I find it fascinating that many aspects of insurance can now be put into the contract itself, as well as the game theory mechanics of blockchain technology that incentivizes people to do the right things.
In addition to this, Australia is currently going through a bad crisis in its farming and agriculture sector. We are at record droughts, and to add to that, there are a number of uncontrollable bush fires currently still raging uncontrollably in certain areas of the country. The farmers are definitely doing it tough here. I thought I'd come up with an example that shows how these people can get an insurance product with guaranteed protection and payment based on certain weather conditions (in this case drought conditions)
What it does
The DApp allows a farmer in a rural area of Australia to purchase a simple insurance contract to insure themselves from drought conditions. For the sake of testing and demonstration, a drought is considered to be in effect if there is no rain in the area for 5 days. A day is currently considered to be 60 seconds instead of 24 hours, but this can be changed via a global parameter.
Once the client purchases the contract, the DApp generates the smart contract on the blockchain with all the required details, and its fully funded to pay out the contract if it deems necessary. Otherwise if the end date/time is reached, the contract ends and returns all funds back to the insurer. The contract also has logic in it to ensure that the weather is checked correctly and consistently, so that the insurer cannot 'game' the contract by not checking the weather. The contract makes use of the Honeycomb weather API to get weather data, and it makes use of a separate custom scheduling Chainlink node which is used to call the function to check the weather once per day. This is required because the insurer can just not call the check weather function if they wish, and eventually the insurance contract would expire and they would not have to pay out. This contract ensures that the weather is checked a correct number of times for the duration of the contract, otherwise at the end the client gets their premium back.
So the contract has 3 possible ending scenarios:
- Drought conditions are reached for the set number of days in a row, contract total cover is paid out to the client
- Drought conditions are not met, and the contract end date comes. If number of requests in the contract equals the number of days the contract was active for - 1 (tolerance of 1 day), then return all funds back to the insurer and mark the contract as ended, otherwise if the number of calls is less than the number of days in the contract duration - 1, then
- Pay the client back their premium, then send remaining funds back to the insurer
How I built it
The contracts were build using truffle and remix, and the DApp was built using NodeJs.
Challenges I ran into
I am not a front end developer, so the front end is very basic, also I ran out of time trying to connect to the scheduling node from a deployed webapp that can't import nodejs libraries, so I had to use an intermediary deployed NodeJs app that takes the request and forwards it to the Chainlink Scheduling Node.
Accomplishments that I'm proud of
I think the Smart Contract and the Contract Factory is fairly good, and shows how an insurer can generate insurance contracts for clients and provide guaranteed execution based on logic and data conditions.
What I learned
I learned alot about making data requests using Chainlink, and also in using the Chainlink node itself, and all the features and flexibility it provides as a blockchain Middleware layer.
What's next for AusCrop Australian Crop Insurance
Refine the DApp, make the front end better, use the aggregator contract to have multiple data sources
Log in or sign up for Devpost to join the conversation.