Skip to content

AlbertGhazaly/AgriGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AgriGuard

AgriGuard is a decentralized weather-based parametric insurance platform built on blockchain technology. It provides automated crop insurance for farmers, protecting them against extreme weather conditions such as droughts and heat stress. The platform uses Chainlink Oracles to fetch real-time weather data and automatically processes claims when predefined weather thresholds are exceeded.

Unlike traditional insurance, AgriGuard operates on a parametric model where payouts are triggered automatically based on objective weather data from Open-Meteo API, eliminating lengthy claim processes and reducing fraud.

🌾 Insurance Coverage Categories

AgriGuard provides three scientifically-backed insurance categories based on agricultural research:

1. Sowing Drought Protection (Rainfall < 60mm)

Protects farmers during the critical planting season when insufficient moisture can prevent seed germination and establishment.

2. Growth Drought Protection (Rainfall < 100mm)

Covers the vegetative and reproductive growth stages when water stress significantly impacts crop yield and quality.

3. Heat Stress Protection (Temperature > 35Β°C)

Safeguards against extreme temperatures that cause crop damage, reduced photosynthesis, and yield loss.

Scientific References:

  • FAO (Food and Agriculture Organization). (2017). "Water for Sustainable Food and Agriculture". Retrieved from https://www.fao.org/3/i7959e/i7959e.pdf
  • IPCC (Intergovernmental Panel on Climate Change). (2014). "Climate Change 2014: Impacts, Adaptation, and Vulnerability". Chapter 7: Food Security and Food Production Systems.
  • Lobell, D.B., & Field, C.B. (2007). "Global scale climate-crop yield relationships and the impacts of recent warming". Environmental Research Letters, 2(1), 014002.
  • Porter, J.R., et al. (2014). "Food security and food production systems". In Climate Change 2014: Impacts, Adaptation, and Vulnerability (pp. 485-533). Cambridge University Press.

✨ Features

πŸ”— Smart Contract (Etherscan)

Etherscan Contract Page

The AutomatedWeatherPolicy smart contract manages all insurance policies, integrates with Chainlink Functions for weather data, and processes automated claims. All transactions are publicly verifiable on the Ethereum Sepolia testnet.


⚑ Chainlink Integration

Chainlink Functions & Automation

Chainlink Functions: Fetches weather data from Open-Meteo API using decentralized oracle network.

Chainlink Automation: Monitors policies daily and triggers automated claim processing when weather thresholds are exceeded.


🏠 Home Page

Home Page

Landing page introducing the platform, explaining parametric insurance, and showcasing the three insurance categories with their scientific thresholds.


πŸ›’ Buy Policy Page

Buy Policy Page

Interactive form for purchasing insurance policies. Users select policy type, coverage duration (30-365 days), farm location coordinates, and see real-time premium calculations before confirming the transaction.


πŸ“Š Dashboard Page

Dashboard Page

Personal dashboard displaying user's policies, coverage statistics, and claim history. Shows active, expired, and claimed policies with detailed information cards.


πŸ“„ Policy Detail Page

Policy Detail Page

Detailed view of a specific policy including insurance type, coverage amount, location coordinates, validity period, weather thresholds, and links to blockchain transactions.


πŸ’° Claim Monitoring Page

Claim Page

Real-time claim monitoring interface displaying all automated claims, payout amounts, timestamps, and direct links to blockchain transactions for verification.


πŸ› οΈ Dependencies

Blockchain (Smart Contracts)

{
  "hardhat": "^2.22.0",
  "@chainlink/contracts": "^1.2.0",
  "@nomicfoundation/hardhat-toolbox": "^5.0.0",
  "dotenv": "^16.4.5",
  "ethers": "^6.x"
}

Key Technologies:

  • Solidity ^0.8.19: Smart contract programming language
  • Hardhat: Ethereum development environment
  • Chainlink Functions: Decentralized oracle for weather data
  • Chainlink Automation: Daily automated upkeep for continuous monitoring
  • OpenZeppelin: Security and utility libraries

Frontend (Client Application)

{
  "react": "^18.3.1",
  "typescript": "5.6.3",
  "vite": "^5.4.20",
  "ethers": "^5.8.0",
  "tailwindcss": "^3.4.17",
  "wouter": "^3.3.5",
  "@radix-ui/react-*": "various",
  "lucide-react": "^0.453.0"
}

Key Technologies:

  • React 18: Modern UI framework
  • TypeScript: Type-safe development
  • Vite: Fast build tool
  • Ethers.js: Ethereum library for blockchain interaction
  • TailwindCSS: Utility-first CSS framework
  • Radix UI: Accessible component primitives
  • Wouter: Lightweight routing

APIs & External Services

  • Open-Meteo API: Weather data provider (historical & forecast)
  • Chainlink Network: Decentralized oracle infrastructure
  • Ethereum Sepolia Testnet: Blockchain network
  • MetaMask: Web3 wallet integration

πŸš€ How to Run

Prerequisites

  • Docker & Docker Compose installed
  • MetaMask browser extension
  • Git for cloning the repository
  • Sepolia ETH for gas fees (get from Sepolia Faucet)

Installation Steps

1. Clone the Repository

git clone https://github.com/yourusername/AgriGuard.git
cd AgriGuard

2. Environment Configuration

Create .env files in both blockchain and client directories:

blockchain/.env

PRIVATE_KEY=your_wallet_private_key
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY
ETHERSCAN_API_KEY=your_etherscan_api_key
CONTRACT_ADDRESS=deployed_contract_address

client/.env

VITE_CONTRACT_ADDRESS=deployed_contract_address
VITE_NETWORK_NAME=sepolia
VITE_ETHERSCAN_URL=https://sepolia.etherscan.io

3. Run with Docker Compose

# Build and start all services
docker-compose up --build -d

# Check service status
docker-compose ps

# View logs
docker-compose logs -f

Services:

4. Access the Application

  1. Open your browser and navigate to: http://localhost:3000
  2. Connect your MetaMask wallet (switch to Sepolia network)
  3. Start purchasing insurance policies!

πŸ‘₯ Team Members

NIM Name
13522138 Andi Marihot Sitorus
13522150 Albert Ghazaly
13522158 Muhammad Rasheed Qais Tandjung

πŸ“‚ Project Structure

AgriGuard/
β”œβ”€β”€ blockchain/                 # Smart contracts & deployment
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   └── WeatherInsurance.sol
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”œβ”€β”€ deploy.js
β”‚   β”‚   β”œβ”€β”€ setSourceCode.js
β”‚   β”‚   β”œβ”€β”€ debug.js
β”‚   β”‚   └── code.js            # Chainlink Functions source code
β”‚   β”œβ”€β”€ hardhat.config.js
β”‚   └── package.json
β”‚
β”œβ”€β”€ client/                     # Frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ BuyPolicy.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PolicyDetail.tsx
β”‚   β”‚   β”‚   └── Claim.tsx
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”‚   β”œβ”€β”€ constant.ts    # Contract ABI & addresses
β”‚   β”‚   β”‚   └── wallet-context.tsx
β”‚   β”‚   └── App.tsx
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ img/                        # Documentation screenshots
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
└── README.md

πŸ“Έ Required Screenshots

Take the following screenshots and save them in the img/ folder:

# Filename Description
1 logo.png AgriGuard logo (from homepage or design)
2 etherscan-contract.png Deployed contract on Sepolia Etherscan
3 chainlink-integration.png Chainlink Functions subscription & Automation upkeep
4 page-home.png Complete homepage with hero and features
5 page-buy-policy.png Full policy purchase form
6 page-dashboard.png Dashboard with stats and policy list
7 page-policy-detail.png Individual policy detail view
8 page-claim.png Claim monitoring page with history

Total: 8 screenshots needed

About

Weather-Based Parametric Insurance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors