{"id":21241532,"url":"https://github.com/shayanb/indemnity","last_synced_at":"2026-04-01T22:04:56.079Z","repository":{"id":71635928,"uuid":"191237030","full_name":"shayanb/indemnity","owner":"shayanb","description":"Blockchain Insurance Project - an initc3 Ethereum bootcamp project","archived":false,"fork":false,"pushed_at":"2019-06-16T18:28:47.000Z","size":758,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-03-27T15:25:23.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://shayanb.github.io/indemnity/index.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shayanb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-10T19:59:53.000Z","updated_at":"2025-09-11T09:17:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f68c37d6-b4b6-4693-95ea-e34286b66de3","html_url":"https://github.com/shayanb/indemnity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shayanb/indemnity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shayanb%2Findemnity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shayanb%2Findemnity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shayanb%2Findemnity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shayanb%2Findemnity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shayanb","download_url":"https://codeload.github.com/shayanb/indemnity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shayanb%2Findemnity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31058993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T19:32:53.857Z","status":"ssl_error","status_checked_at":"2026-03-27T19:32:45.136Z","response_time":164,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T00:56:04.154Z","updated_at":"2026-04-01T22:04:55.851Z","avatar_url":"https://github.com/shayanb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crop Insurance on Blockchain\nA 2019 [initc3](https://www.initc3.org/events/2019-06-10-IC3-Blockchain-Boot-Camp.html) bootcamp project, built on Ethereum. \n\n**Slides**: https://docs.google.com/presentation/d/1esDRIJ6rhfc185wXPz6Q08MYKb9XoIUcYrCvQlrSdNI/edit?usp=sharing\n\n**Live Demo**: https://shayanb.github.io/indemnity/index.html\n\n\n# Overview\n\nThe following documentation outlines an MVP for a peer to peer crop insurance ecosystem, powered by Ethereum. The objective of this MVP is to drive a holistically enhanced customer experience by enabling direct connectivity between demand-side (Insurance Buyers) and supply-side (Insurance Providers) participants and ensuring guaranteed, timely payouts of premiums and policies when applciable.  \n\nAdditionally, this MVP serves to demonstrate the coexistence of a robust, seamless secondary trading marketplace for digital insurance contracts, and the benefits of facilitating that marketplace on the same rails utilized for the primary creation process. \n\n### Scope of MVP:\n- Policy Creation: An Insurance Buyer submits an initial request for a new insurance policy that includes all desired terms; Insurance Providers view the requests and determine if they choose to accept the requests. \n\n- Claim Submission: Insurance Buyers submit off-chain claims to the chosen Oracle, requesting a determination that total crop failure has occurred prior to policy expiry. Oracles either reject the claim, or provide the Insurance Buyer with a signed message, indicating that total crop failure has occured. \n\n- Policy Expiry: \n\n- Trading: \n\nThis MVP does not yet address: plot and land registries, bidding, matching, partial crop failures, premium \u0026 payout reinvestment options, market-making, among other functionalities. See below for further discussion. Payments are currently made in ETH; however, a future-state version may require the use of a more stable currency, or at least the ability to specify alternatives. \n\n## Actors\n- **Insurance Buyers:** Farmers and landowners looking to purchase crop insurance to protect against the event of failed harvests\n    - Note: farmers could independently insure their crops through this market, or pool assets to unlock lower premiums \n    \n- **Insurance Providers:** Independent actuaries and smaller insurance companies who can provide coverage to Insurance Buyers in the event of crop failure and generate revenue from premiums in the absence of crop failure. Their decision to engage in the market is typically based on an assesment of risk factors, an analysis process that's typically unique to each provider. \n\n- **Oracles:** trusted data sources that can verify the outcome of whether or not a crop has failed\n    - Note: Oracles are not required to directly participate in the network within this MVP\n    - Potential oracles: \n        - Satellite data\n        - Trusted evaluation firms\n        - Sensors\n        \n- **Insurance Traders:** Insurance Providers can be Insurance Traders\n    - Motivations for trading can be varied, most notably including: diversification of risk, definite profit opportunities  \n\n-------------------------------\n\n## Workflow\n\n\n### 1. Policy Creation\nActors: Insurance Buyer, Insurance Trader\n\nConditions: *need to fill in*\n\nProcess:  \n\nA Farmer will create a proposal for insuring a plot of their land, then submit to the Insurance Provider marketplace. The proposal contains the following terms: \n\n- Plot ID - one plot ID per proposal (Specified within plot registry: Total Size (km2) - total area covered by all plots included within contract)\n- Start Date - when the policy would start\n- End Date - when the policy would expire\n- Premium (ETH / km2) - amount per km2 paid by the farmer for the insurance protection in the event that crop failure does not occur \n- Payout (ETH / km2) - amount per km2 of protection that the farmer seeks and would be guaranteed by an insurance provider in the event of crop failure \n- Approved Oracle(s) - approved data provider(s) who will be ultimately responsible for verifying any claims of failure up till and including expiry; corresponds to a whitelist of approved and trusted public keys \n\nAt submission, the farmer also transfers the total premium amount (ETH) to the proposal.\n\nBefore the submitted proposal is confirmed, there is a check to ensure that the submitter (the Farmer) is the listed owner of that plot\n\nThe premium sits within the proposal and away from the farmer, but remains unlocked (farmer is able to withdraw), and the terms of the proposal can be modified accordingly, until the proposal is accepted by an Insurance Provider. \n\nAn Insurance Provider will be able to view the proposal and choose to accept. At acceptance, the Insurance Provider also commits (sends) the total payout amount ($) to the proposal. \n\nOnce accepted, and the funds from the Insurance Provider are deposited, the proposal is complete and is a fully formed contract or policy. \n\n\n### 2. Claim Submission\nActors: Insurance Buyer, Oracle\n\nConditions: \n\n*Need to complete*\n- Insurance contract is still valid\n- Current date must be equal to or less than date of expiry \n\nProcess:\n\nThe Farmer will contact the Oracle, indicating they are raising an insurance claim, and request for a verification of the state of the Plot(s). This communication will take place off-chain. \n\nThe Oracle will address the following question: has total crop failure occurred for the total plot within this contract? This determination (i.e. analysis of data) will take place off-chain. \n\n   - If NO (total crop failure has not occurred): the workflow is complete. \n\n   - If YES (total crop failure has occurred): The Oracle will then sign a transaction indicating Yes (total crop failure has occurred) with their trusted private key. This transaction will be submitted to the network by the farmer. \n        - There will be an automated verification process, confirming that the signature provided by the Oracle does, indeed, match one of the pre-specified trusted public keys (a determination made originally within the Farmer’s proposal). This will occur on-chain. \n        - Total payout and total premium are released to the Farmer\n        - The Insurance Policy is no longer valid \n\n\n### 3. Expiry\nActors: Insurance Provider\n\n*Need to complete*\n\nConditions: \n- Current date is after expiry date\n- Policy ID exists \n- Requester is a listed insurance provider with stake in the policy; their stake still exists\n- No claims have been made on this policy\n- Message sender has not previously withdrawn funds from this contract\n\nAfter expiry date, if no claims have been made and both payout and premium exist within the contract, the Insurance Provider will be able to withdraw funds from the contract. The Insurance Provider will submit a transaction requesting this withdrawal, and if all conditions are met, both premium and payout is sent to the Insurance Provider, in accordance with their ownership stake in thep policy.  \n\n### 4. Trading\nActors: Insurance Provider, Insurance Trader\n\n*Need to edit*\nConditions: \nInsurance contract is still valid\nCurrent date must be equal to or less than date of expiry\n\nWorkflow:\nThe Insurance Provider (Existing Holder) seeks to exit their total position or percentage of their position held within an Insurance Policy. \n\nThe Insurance Provider (Existing Holder) will create a request to sell, specifying: \n- Change in Payout (ETH) - This is effectively the price of the trade. Trade settlement completes once the Insurance Trader deposits this amount into the Insurance Policy, and the same amount is withdrawn and transferred to the Insurance Provider, decreasing their liability position within the policy in the event of crop failure. This number must be equal to or less than the total payout amount of the policy.\n\n- Change in Premium (ETH) - This amount corresponds to the change in ownership stake that the Insurance Provider has in the total premium. After trade settlement, this amount would be owed to the Insurance Trader instead of the Insurance Provider in the event crop failure. \n\nThe Insurance Provider would then submit the request to the marketplace. \n\nThe Insurance Trader (another Insurance provider) who seeks to enter into or expand position within the same Insurance Policy would accept the terms of the trade. In doing so, the Insurance Trader must send the total amount corresponding to the price of the transfer (ETH) to the Insurance Contract. That same amount is then released from the contract and sent to the Insurance Provider. The ownership positions are updated accordingly. The Insurance Trader is now a listed Insurance Provider within the policy. \n\n## Future-State\n- Plot Registries\n- Bidding\n- Insurance Provider proposals + Matching engine\n- Partial crop failures\n- Exchange and market-making tools\n- Premium and payout reinvestment options\n- More flexibility with Oracles (i.e. approval rules - k of N Oracle approvals, etc.) \n\n\n# Security Consideration\n- Oracles \n- Double Indemnity\n- Payout safety\n\n\n# API Design\n\n## Data Structures\n\n```\nstruct plot {\n    uint plotId;\n    address owner;\n}\n```\n\n```\nstruct insuranceRequest {\n    uint plotId;\n    uint startDate;\n    uint endDate;\n    uint premium;\n    unit coverRequired;\n}\n```\n\n```\nstruct policy {\n    uint policyId;\n    mapping(address =\u003e uint) collateralLiabilities;\n    mapping(address =\u003e uint) premiumDividends;\n    mapping(address =\u003e boolean) premiumDividendPayouts;\n    uint startDate;\n    uint endDate;\n}\n```\n\n```\nstruct tranche {\n    address seller;\n    uint collateralLiabilityChange;\n    boolean sold;\n}\n```\n\n```\npublic plot[] plots;\npublic insuranceRequest[] insuranceRequests;\npublic policy[] policies;\npublic tranche[] tranches;\n```\n\n## Functions\n\n* **submitInsuranceRequest**\n  * plotId, startDate, endDate, premium, coverRequired\n\n    * require(plots[plotId] != 0)\n    * require(msg.sender == plots[plotId].owner)\n    * require(msg.value == premium)\n    * require(premium \u003c coverRequired)\n    * require(startDate \u003e now)\n    * require(endDate \u003e startDate)\n    * require(endDate - startDate \u003c 365 days)\n\n* **cancelInsuranceRequest**\n  * insuranceRequestId\n\n    * require(insuranceRequests[insuranceRequestId] != 0)\n    * require(policies[insuranceRequestId] == 0)\n    * require(msg.sender == plots[plotId].owner)\n\n * **submitClaim**\n   * policyId, claimAmount\n\n     * require(policies[policyId] != 0)\n     * require(msg.sender == policies[policyId].insuredParty)\n     * require(policies[policyId].endDate \u003e now)\n     * require(verifiers[ecrecover(hash, v, r, s)] != 0)\n     * require(policies[policyId].claimAmount \u003c= policies[policyId].totalCollateral)\n\n * **provideCover**\n   * insuranceRequestId\n\n     * require(insuranceRequests[insuranceRequestId] != 0)\n     * require(msg.value == insuranceRequests[insuranceRequestId].coverRequired)\n     * require(msg.sender != insuranceRequests[insuranceRequestId].insuredParty)\n\n * sellPolicyPremiumDividend\n   * collateralLiabilityChange, premiumDividendChange, policyId\n\n     * require(policies[policyId] != 0)\n     * require(policies[policyId].collateralLiabilities[msg.sender] != 0)\n     * require(policies[policyId].premiumDividends[msg.sender] != 0)\n     * require(policies[policyId].collateralLiabilities[msg.sender] \u003e collateralLiabilityChange)\n     * require(policies[policyId].premiumDividends[msg.sender] \u003e premiumDividendChange)\n\n * **cancelPolicyPremiumDividendSale**\n   * trancheId\n\n     * require(msg.sender == tranches[trancheId].seller)\n     * require(tranches[trancheId].sold != true)\n\n\n * **buyPolicyPremiumDividend**\n   * tracheId\n\n      * require(tranches[trancheId] != 0)\n      * require(tranches[trancheId].sold != true)\n      * require(msg.value == tranches[tranchId].collateralLiabilityChange)\n      * require(msg.sender != tranches[trancheId].seller)\n\n * **requestPolicyPremiumPayout**\n   * policyId\n\n     * require(policies[policyId] != 0)\n     * require(policies[policyId].endDate \u003c now)\n     * require(policies[policyId].collateralLiabilities[msg.sender] != 0)\n     * require(policies[policyId].premiumDividends[msg.sender] != 0)\n     * require(policies[policyId].premiumDividendPayouts[msg.sender] != true)\n\n# Diagrams\n\n![Initial Workflow](./assets/img/blockchain-insurance-workflows.png)\n\n![Work Sequence](./assets/img/insurance-sequence.png)\n\n![Tranche Sale Workflow](https://i.ibb.co/dbLmZRw/blockchain-insurance-Page-3.png)\n\n![Tranche Sale Workflow](https://i.ibb.co/NpXgtKH/crop-grower-dashboard.png)\n\n![Tranche Sale Workflow](https://i.ibb.co/sFgJSyM/Screenshot-2019-06-14-at-02-52-23.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshayanb%2Findemnity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshayanb%2Findemnity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshayanb%2Findemnity/lists"}