Decentralized Peer-to-Peer Weather Insurance Protocol
RainGuard is a decentralized insurance protocol that uses trusted weather data to trigger automatic payouts for climate-related risks. It enables anyone to build tailored protection against unpredictable weather events like droughts, heatwaves, or storms, without dealing with traditional insurers or slow, manual claims processes.
- Weather-Based Insurance: Create custom insurance policies based on specific weather conditions, locations, and timeframes
- Expert-Driven Pricing: Risk experts compete to offer the best premium rates through transparent bidding
- Automated Payouts: Smart contracts automatically trigger payouts when weather conditions are met
- Gasless Transactions: Circle Paymaster integration enables gasless transactions paid in USDT
- Reputation System: Experts build reputation scores based on their risk assessment accuracy
- Real-Time Data: Chainlink Functions integration with AccuWeather for reliable weather data
- User-Friendly Interface: Clean, intuitive UI designed for users with no blockchain experience
The protocol consists of several smart contracts deployed on Mantle and Zircuit:
InsuranceManager: Core contract handling the entire insurance lifecycleReputation: Manages expert reputation scores and performance trackingEventsLib: Event definitions for contract interactionsMockUSDC: Test USDC token for developmentOracleMock: Mock oracle for testing weather data integration
Built with modern web technologies:
- Next.js 15 (App Router) with TypeScript
- Scaffold-ETH 2 hooks for seamless blockchain interactions
- RainbowKit for wallet connections
- Tailwind CSS with DaisyUI for styling
- Wagmi for Ethereum interactions
- Request Creation: Users create insurance requests with coverage amount, location, timeframe, and weather conditions
- Expert Bidding: Risk experts submit offers with premiums and risk assessments
- Offer Selection: Users select the best offer based on premium and expert reputation
- Pool Funding: Investors fund the payout pool with USDC
- Premium Payment: Users pay premiums, automatically distributed to experts (5%) and investors (95%)
- Policy Activation: Smart contract activates the policy for the specified timeframe
- Automatic Settlement: Chainlink Functions fetch weather data and trigger payouts if conditions are met
- Reputation Update: Expert reputation scores are updated based on payout accuracy
- Solidity ^0.8.0
- Hardhat for development and testing
- OpenZeppelin contracts for security
- Chainlink Functions for oracle integration
- Circle Paymaster for gasless transactions
- Next.js 15 with App Router
- TypeScript for type safety
- Wagmi + RainbowKit for Web3 integration
- Tailwind CSS + DaisyUI for styling
- React Query for data fetching
- Zustand for state management
- Node.js >= 20.18.3
- Yarn package manager
- Git
-
Clone the repository
git clone <repository-url> cd RainGuard
-
Install dependencies
yarn install
-
Set up environment variables
cp packages/hardhat/.env.example packages/hardhat/.env cp packages/nextjs/.env.example packages/nextjs/.env
-
Start local development
# Start local blockchain yarn chain # Deploy contracts (in a new terminal) yarn deploy # Start frontend (in a new terminal) yarn start
-
Access the application
- Frontend: http://localhost:3000
- Debug interface: http://localhost:3000/debug
-
Create Insurance Request
- Navigate to the "Create Request" page
- Define weather conditions (rain, wind, temperature, etc.)
- Set coverage amount, location, and timeframe
- Submit your request
-
Review Expert Offers
- Browse offers from risk experts
- Compare premiums and reputation scores
- Select the best offer for your needs
-
Pay Premium
- Once the pool is funded, pay your premium
- Premium is automatically distributed to experts and investors
-
Monitor Policy
- Track your policy status in real-time
- View countdown to policy expiry
- Receive automatic payout if conditions are met
-
Submit Offers
- Review open insurance requests
- Analyze weather risks and historical data
- Submit competitive premium offers with detailed assessments
-
Build Reputation
- Earn reputation points for accurate risk assessments
- Avoid penalties for mispriced risks
- Establish credibility in the ecosystem
-
Fund Pools
- Browse available insurance pools
- Contribute USDC to fund payouts
- Earn returns if no payout is triggered
-
Monitor Investments
- Track funding progress in real-time
- View potential returns and risks
- Withdraw funds after policy settlement
# Blockchain
yarn chain # Start local blockchain
yarn deploy # Deploy contracts
yarn test # Run tests
yarn compile # Compile contracts
# Frontend
yarn start # Start development server
yarn build # Build for production
yarn lint # Run linter
yarn format # Format code
# Deployment
yarn vercel # Deploy to Vercel
yarn ipfs # Deploy to IPFScreateRequest(): Create new insurance requestsubmitOffer(): Submit expert offerselectOffer(): Select winning offerfundPool(): Fund insurance poolpayPremium(): Pay insurance premiumsettlePolicy(): Settle policy with weather data
getRequestBasic(): Get basic request informationgetOffers(): Get all offers for a requestgetOfferById(): Get specific offer detailsgetInvestments(): Get pool investmentsgetConditions(): Get weather conditionsgetAllRequestIds(): Get all request IDs
- OpenZeppelin: Industry-standard security contracts
- Comprehensive Testing: Full test coverage for all contracts
- Access Control: Role-based permissions and ownership controls
- Oracle Security: Chainlink Functions for reliable data feeds
- Gas Optimization: Efficient contract design for cost-effective operations
- Mantle
- Zircuit
- Mantle Testnet
- Local Hardhat
- InsuranceManager:
0x7C655115aC55C333Fa6B392C5984698AB60d020f - Explorer: https://explorer.zircuit.com/address/0x7C655115aC55C333Fa6B392C5984698AB60d020f
- InsuranceManager:
0x9847C817983D90faA45bC71bCa461AD8f246f2e9 - Explorer: https://explorer.mantle.xyz/address/0x9847C817983D90faA45bC71bCa461AD8f246f2e9
RainGuard - Insurance without middlemen, powered by data and governed by its participants.