The screenshots below are in order of use: from opening the app through connecting the wallet, entering details, confirming the transaction, and seeing the result. Recruiters can follow the full flow without running the app.
A blockchain-based parametric disaster insurance application. Users purchase policies by paying a premium and providing a risk score; an admin can trigger payouts (5× premium) for valid policies within the policy window.
This repository contains a full-stack dApp for parametric disaster insurance:
- Smart contract — On-chain policy creation and payout logic (Solidity).
- Blockchain tooling — Hardhat for local development, testing, and deployment.
- Frontend — React (Vite) app for wallet connection and policy purchase.
- Backend — Placeholder for a future risk-score API.
The system is intended for development and demonstration on a local Hardhat network. No real funds are used.
Traditional disaster insurance often involves slow, opaque claims and centralized underwriting. This project explores a parametric model:
- Parametric — Payout conditions are predefined (e.g. admin-attested qualifying event).
- On-chain — Policies and payouts are recorded on a blockchain for transparency and auditability.
- Transparent rules — Minimum risk score, policy duration (30 days), and payout multiplier (5×) are enforced in the contract.
- Purchase insurance — Connect MetaMask, enter risk score (60–100) and premium (ETH), and buy a policy in one transaction.
- On-chain policies — Each policy is stored on the contract with a unique ID, premium, risk score, and expiry.
- Admin payouts — Designated admin can trigger one payout per policy (5× premium) before the 30-day window expires.
- Service-layer frontend — Clear separation between UI, risk logic, and contract interaction; ready for a future risk-score API.
- Test suite — Hardhat tests for deployment, purchase, payout, admin, and view functions.
contracts/— Solidity source (DisasterInsurance.sol).blockchain/— Hardhat config, deploy/utility scripts, and tests (contracts compiled from../contracts).frontend/— React app and services (wallet, risk, insurance); reads contract address and ABI from config.backend/— Future API for risk score calculation.docs/— Architecture, deployment, smart contract design, and walkthrough.
High-level flow: User → Frontend (MetaMask) → Local chain → Contract. Admin actions (payouts) are performed via scripts or a future admin UI.
See docs/architecture.md and docs/system-design.md for details.
| Layer | Technology |
|---|---|
| Smart contract | Solidity ^0.8.24 |
| Blockchain | Hardhat (local node, compile, test) |
| Frontend | React, Vite, ethers.js v5 |
| Wallet | MetaMask (or compatible) |
| Backend | Planned (e.g. Node/Express) |
- Constants: Policy duration 30 days, payout 5× premium, minimum risk score 60 (max 100).
- Roles: Single
admin(deployer by default); only admin can calltriggerPayoutandchangeAdmin. - State: Policies stored by ID; each policy has policyholder, premium, purchase time, risk score, and
payoutClaimedflag. - Events:
PolicyPurchased,PayoutTriggered.
See docs/smart-contract-design.md for full design and security notes.
- Node.js v16+
- npm
- MetaMask (for the frontend)
# From project root
cd blockchain && npm install --legacy-peer-deps
cd ../frontend && npm install
cd ..
npm run compile-
Terminal 1 — start node:
npm run node
Leave it running. -
Terminal 2 — deploy:
npm run deploy
Copy the printed contract address. -
Configure frontend:
Openfrontend/src/config/contract.jsand setCONTRACT_ADDRESSto the address from step 2. -
Optional — fund MetaMask:
SetRECIPIENTto your MetaMask address and runnpm run fund(with the node running). -
Start frontend:
cd frontend && npm run dev
Open http://localhost:5173 and add the Hardhat Local network in MetaMask (RPChttp://127.0.0.1:8545, Chain ID31337).
Detailed steps and troubleshooting: docs/RUN_PROJECT.md and docs/deployment-guide.md.
- Follow the setup above (node running, contract deployed, frontend configured and running).
- In the app: click Connect MetaMask, then enter Risk Score (e.g. 75) and Premium (ETH) (e.g. 0.1).
- Click Buy Insurance and confirm the transaction in MetaMask.
- To trigger a payout as admin: update
CONTRACT_ADDRESSandPOLICY_IDinblockchain/scripts/triggerPayout.js, then run:See docs/ADMIN_PAYOUT_GUIDE.md for full admin flow.cd blockchain && npx hardhat run scripts/triggerPayout.js --network localhost
| Document | Description |
|---|---|
| docs/architecture.md | High-level architecture and components |
| docs/system-design.md | Problem, goals, and subsystems |
| docs/deployment-guide.md | Build, run, and deploy steps |
| docs/smart-contract-design.md | Contract design and security |
| docs/frontend-backend-flow.md | Frontend–backend and future API |
| docs/walkthrough.md | Step-by-step flow and design decisions |
| docs/RUN_PROJECT.md | How to run the project |
| docs/ADMIN_PAYOUT_GUIDE.md | Admin payout and verification |
A blockchain-based insurance platform that calculates policy eligibility using location-based natural calamity risk scores. Developed Solidity smart contracts with Hardhat and Ethers.js, integrated MetaMask for transactions, and implemented premium-based payouts with an admin settlement process.
2a80615409b98c02fd541a3dc0ed018995c7c2de









