A blockchain-based parametric insurance platform for event cancellations using weather data oracles and smart contracts.
WeInsure provides automated insurance coverage for events based on weather conditions. The platform uses Chainlink oracles to fetch real-time weather data and automatically triggers payouts when predefined weather thresholds are met.
- Parametric Insurance: Automated payouts based on objective weather data
- Blockchain-Based: Transparent, immutable smart contracts on Ethereum
- Oracle Integration: Real-time weather data from multiple sources
- NFT Policies: Each policy is represented as an NFT for easy ownership tracking
- Award-Winning UI/UX: Professional, accessible design with 3-color palette
- Wallet Isolation: Each wallet gets its own separate policy dashboard
- Modern Frontend: Clean Next.js application with seamless Web3 integration
- Automated Triggers: No claims process - payouts are automatic when conditions are met
- Real-time Notifications: Professional notification system with visual indicators
- Mobile Optimized: Responsive design that works perfectly on all devices
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Backend β β Blockchain β
β (Next.js) βββββΊβ (Node.js) βββββΊβ (Sepolia) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Web3 Wallet β β MongoDB β β Smart β
β (MetaMask) β β Weather APIs β β Contracts β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- PolicyFactory: Creates and manages insurance policies
- PolicyNFT: ERC721 tokens representing insurance policies
- Escrow: Manages premium payments and payouts
- TriggerContract: Handles weather data and trigger logic
- Award-Winning UI/UX: Professional 3-color design system with optimal accessibility
- Clean Architecture: Component-based design with consistent styling
- Web3 Integration: Seamless wallet connection with RainbowKit
- Wallet-Specific Data: Isolated policy data for each connected wallet
- Real-time Monitoring: Live weather data and risk visualization
- Responsive Design: Mobile-first approach with smooth animations
- Professional Components: Clean cards, tables, forms, and navigation
- Premium Calculator: Actuarial calculations based on historical weather data
- Weather API Integration: Fetches data from multiple weather services
- MongoDB Database: Stores policy metadata and weather history
- Multi-Source Weather Data: OpenWeatherMap, NOAA, backup APIs
- Consensus Mechanism: Validates data across multiple sources
- Chainlink Integration: Submits verified data to blockchain
- Node.js >= 18.0.0
- MongoDB
- Ethereum wallet with Sepolia testnet ETH
- API keys for weather services (optional for testing)
- Clone the repository
git clone https://github.com/YOUR_USERNAME/WeInsure.git
cd WeInsure- Install all dependencies
npm run install:all- Configure environment variables
# Copy example files and configure with your API keys
cp .env.example .env
cp backend/.env.example backend/.env
cp oracle-adapter/.env.example oracle-adapter/.env
cp frontend/.env.example frontend/.env.local
# Edit each .env file with your actual API keys and configuration
# See the .env.example files for detailed comments on each variable- Compile and deploy smart contracts
npm run compile
npm run deploy:sepolia- Setup frontend with contract addresses
npm run setup:frontend- Start all services
npm run devThis will start:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Oracle Adapter: Weather monitoring service
WeInsure features a professional, clean design system built with modern web standards:
- Professional 3-Color Palette:
- Primary Blue (
#2563eb) - Trust and reliability - Neutral Gray (
#64748b) - Clean readability - Success Green (
#10b981) - Positive actions
- Primary Blue (
- Typography: Inter font family for optimal readability
- Accessibility: WCAG compliant color contrasts and interactions
- Responsive: Mobile-first design approach
- Clean Navbar: Professional navigation with wallet integration
- USDC Balance Display: Real-time balance tracking with visual indicators
- Responsive Menu: Smooth mobile navigation experience
- Active States: Clear indication of current page location
- Multi-Step Form: Intuitive policy creation workflow
- Real-time Validation: Instant feedback on form inputs
- Premium Calculator: Live premium calculation with breakdown
- Weather Threshold Setup: Visual threshold configuration
- Smart Contract Integration: Seamless blockchain interactions
- Wallet-Specific Data: Each wallet has isolated policy data
- Summary Cards: Clean metric displays with hover animations
- Active Policy Monitor: Real-time weather risk visualization
- Policy History Table: Professional table design with status badges
- Live Risk Monitor: Progress bars showing current vs trigger thresholds
- Notification System: Clean notification cards with read/unread states
- Real-time Updates: Instant notifications for policy events
- Visual Indicators: Unread badges and status indicators
- Persistent Storage: Notifications persist across sessions
- Clean UI: Professional notification cards with proper hierarchy
- Responsive Design: Optimized for all screen sizes
- Touch-Friendly: Proper touch targets and interactions
- Performance: Smooth animations and transitions
- Accessibility: Screen reader compatible and keyboard navigable
- Hero section with clear value proposition
- Feature highlights and platform statistics
- How it works explanation
- Call-to-action sections
- Step 1: Event details and location
- Step 2: Weather thresholds configuration
- Step 3: Review and payment
- Real-time premium calculation
- Smart contract integration
- Policy overview and statistics
- Real-time weather monitoring
- Policy status tracking
- Quick actions and navigation
- Live weather charts (24h history)
- Policy risk assessment
- Alert system for critical conditions
- Multi-policy monitoring
npm run install:all # Install all dependencies
npm run dev # Start all services (frontend, backend, oracle)
npm run compile # Compile smart contracts
npm test # Run contract tests
npm run deploy:sepolia # Deploy to Sepolia testnet
npm run verify:sepolia # Verify contracts on Etherscan# Frontend
npm run frontend:dev # Start frontend development server
npm run frontend:build # Build frontend for production
# Backend
npm run backend:dev # Start backend development server
npm run backend:start # Start backend production server
# Oracle Adapter
npm run oracle:dev # Start oracle with auto-restart
npm run oracle:start # Start oracle production modenpm run setup:frontend # Setup frontend with contract addresses
npm run setup:testnet # Setup testnet environment
npm run interact # Test contract interactions
npm run monitor # Monitor policies and weathernpm test # Run all tests
npm run test:coverage # Run with coverage report
npm run test:gas # Analyze gas usageWeInsure Integration Tests
β
Should complete full policy lifecycle - normal weather
β
Should complete full policy lifecycle - cancellation trigger
PolicyFactory
β
Should create a policy successfully
TriggerContract
β
Should register trigger conditions
β
Should process weather data and trigger cancellation
β
Should calculate 24-hour rainfall correctly
6 passing (2s)
- Connect Web3 wallet to frontend
- Fill out event details and location
- Set weather thresholds for triggers
- System calculates premium using actuarial models
- Pay premium in USDC and receive Policy NFT
- Oracle adapter polls weather APIs hourly
- Data validated using consensus mechanism
- Frontend displays real-time weather charts
- Risk levels calculated and displayed
- Postponement: Wind β₯ threshold for consecutive hours β 50% payout
- Cancellation: Rain β₯ threshold in 24h OR wind β₯ threshold β 100% payout
- Payouts are automatic and instant
- Policy NFT status updated
- Postponement Rainfall: Typically 10-15mm in 1 hour
- Postponement Wind: Typically 50-60 km/h sustained
- Cancellation Rainfall: Typically 20-25mm in 24 hours
- Cancellation Wind: Typically 80-100 km/h
ExpectedLoss = (Postponement% Γ Coverage Γ Prob_p) + (100% Γ Coverage Γ Prob_c)
PurePremium = ExpectedLoss
LoadedPremium = PurePremium / (1 - TargetLossRatio)
- Multi-source Oracle Consensus: Prevents single point of failure
- OpenZeppelin Standards: Battle-tested smart contract implementations
- Access Control: Role-based permissions throughout
- Reentrancy Protection: All external calls are protected
- Input Validation: Comprehensive parameter validation
- Sepolia Testnet β (Primary development network)
- Ethereum Mainnet (Production ready)
- Polygon (Future deployment)
- Arbitrum (Future deployment)
WeInsure/
βββ contracts/ # Smart contracts
β βββ PolicyFactory.sol
β βββ PolicyNFT.sol
β βββ Escrow.sol
β βββ TriggerContract.sol
β βββ mockERC20.sol
βββ frontend/ # Next.js frontend with award-winning UI/UX
β βββ app/ # App router pages with clean layouts
β β βββ components/ # Professional reusable components
β β βββ dashboard/ # Wallet-specific dashboard
β β βββ create-policy/ # Multi-step policy creation
β β βββ globals.css # Professional 3-color design system
β βββ lib/ # Utilities and API client
βββ backend/ # Node.js backend
β βββ src/
β β βββ controllers/ # API controllers
β β βββ models/ # Database models
β β βββ routes/ # API routes
β β βββ services/ # Business logic
β βββ server.js
βββ oracle-adapter/ # Weather oracle service
β βββ index.js # Main oracle service
β βββ weather-fetcher.js # Weather API integration
β βββ consensus.js # Data validation
β βββ chainlink-integration.js
βββ scripts/ # Deployment and utility scripts
βββ test/ # Smart contract tests
βββ package.json # Main project configuration
- Connect Wallet β Clean wallet connection interface with professional styling
- Wallet Isolation β Each wallet gets its own isolated policy dashboard
- Create Policy β Intuitive multi-step form with real-time validation
- Visual Feedback β Professional notifications and status updates
- Monitor Weather β Clean dashboard with live risk visualization
- Automatic Payouts β Instant notifications when payouts are triggered
- Policy Management β Professional table interface for policy history
- Professional Aesthetics: Clean, modern design suitable for financial applications
- Optimal Readability: High contrast colors and proper typography
- Smooth Interactions: Subtle animations and hover effects
- Mobile Optimized: Responsive design that works on all devices
- Accessibility First: WCAG compliant design for all users
npm run dev # Starts all services locally- Smart Contracts: Deploy to mainnet using deployment scripts
- Backend: Deploy to cloud service (AWS, GCP, etc.)
- Frontend: Deploy to Vercel or similar platform
- Oracle: Run as a service with proper monitoring
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: Check the README and code comments
- Discussions: GitHub Discussions
WeInsure - Protecting events with blockchain-powered parametric insurance π‘οΈβοΈ