ChainGuard
Parametric DeFi insurance that automatically pays out when Ethereum gas fees spike — powered by Chainlink CRE.
What it is
The Problem
Ethereum gas fee spikes are unpredictable and devastating for time-sensitive DeFi users. A trader in Lagos trying to send a remittance, a protocol executing a liquidation, or a DAO submitting a governance vote can suddenly face gas fees 10-50x above normal. Unlike traditional finance where fee structures are capped and predictable, blockchain users have no recourse when network congestion strikes at the worst possible moment.
According to Chainalysis, Sub-Saharan Africa had the fastest-growing crypto adoption in 2023, with users relying heavily on stablecoins for remittances. A $5 gas spike on a $20 remittance is a 25% hidden tax — and it happens with zero warning.
The Solution
ChainGuard v2 is a parametric insurance protocol that protects DeFi users against Ethereum network congestion. Unlike claim-based insurance (which requires human adjudicators and weeks of processing), parametric insurance pays out automatically when a predefined on-chain condition is met — no paperwork, no disputes, no delays.
Users buy a coverage policy as an ERC-721 NFT. If the Ethereum base fee exceeds their chosen threshold for a consecutive number of reporting cycles, a Chainlink CRE workflow automatically triggers a USDC payout to their wallet.
How It Works
- Policy Purchase — User selects a tier (Flash: 80 gwei threshold, Storm: 60 gwei, Hurricane: 40 gwei), pays a USDC premium, and receives a policy NFT.
- Monitoring — A Chainlink CRE workflow runs on a cron schedule every 15 minutes:
- Fetches current gas price from an external gas oracle (HTTP Client)
- Reads on-chain state via getCongestionStatus() (EVM Read)
- Achieves DON consensus on the gas value (Consensus / Median aggregation)
- Writes the result on-chain via reportCongestion() (EVM Write)
- Payout — When reportCongestion() is called and the base fee exceeds a policy's threshold for N consecutive cycles, the Insurance contract automatically calls the Vault to transfer USDC to the policyholder.
- Dashboard — A live Next.js frontend shows real-time network status, active policies, and payout history by reading directly from the contract.
Proven End-to-End
We ran a full payout simulation on Tenderly Virtual TestNet:
- Purchased a Flash tier policy (80 gwei threshold, $100 USDC coverage)
- Submitted 5 consecutive reports at 100 gwei
- Contract automatically triggered a $10 USDC payout in the same transaction
How it Works
Smart Contracts (Solidity 0.8.24)
- ChainGuardInsurance.sol — Core logic: policy registration, congestion reporting, breach detection, payout triggering
- ChainGuardVault.sol — USDC liquidity pool; handles premium collection and claim disbursement
- ChainGuardPolicyNFT.sol — ERC-721 policy tokens with on-chain metadata
- MockUSDC.sol — ERC-20 test stablecoin (6 decimals, mintable)
Chainlink CRE Workflow (TypeScript) - Built with @chainlink/cre-sdk and @chainlink/cre-capabilities
- 5-capability pipeline: Cron Trigger → HTTP Fetch → EVM Read → DON Consensus → EVM Write
- Deployed workflow: cre-workflow/congestion-monitor/main.ts
Frontend (Next.js 14 + TypeScript) - wagmi v2 + ConnectKit for wallet connection
- viem for contract reads; useReadContract with 15-second polling
- Live monitor page reads getCongestionStatus() directly from the deployed contract
- Deployed to Vercel: https://chainguard-v2.vercel.app
Testing & Devops - Hardhat + TypeScript for contract compilation and deployment scripts
- Tenderly Virtual TestNet (Chain ID 73571) for live exploreable test environment
- End-to-end payout test: scripts/test-payout.ts
Links
Created by
- Godswill