A blockchain-based parametric insurance platform for gig economy workers. Workers purchase daily coverage and receive instant payouts when accidents occur.
All smart contracts are deployed and live on Shardeum EVM Testnet (Mezame).
- Network: Shardeum EVM Testnet (Mezame)
- Chain ID: 8119
- RPC URL: https://api-mezame.shardeum.org
- Explorer: https://explorer-mezame.shardeum.org
- Native Token: SHM
| Contract | Address | Explorer |
|---|---|---|
| InsurancePolicy | 0x3A84E06554876A557b16249619247eF765C35407 |
View |
| ClaimPayout | 0xf678B23d7887d9c9dbc49C2170902d5c88075c2D |
View |
| ReputationScore | 0x199678E7AF0B7a9f62523563f9eF861e242e944A |
View |
Note: ClaimPayout contract currently holds 100 SHM (requires 150 SHM per payout).
Manages the insurance policy lifecycle. Workers purchase 24-hour coverage by sending 5 SHM premium. The contract automatically tracks policy expiration, prevents duplicate purchases during active coverage, and allows the owner to withdraw collected premiums. Each policy includes coverage amount, expiration timestamp, and claim status.
Key Functions:
buyDailyCoverage()- Purchase 24-hour coverage (5 SHM)checkMyCoverage()- View active coverage statuswithdrawPremiums()- Owner collects premiums
Handles claim filing, approval, and payout distribution. Validates active coverage before accepting claims, prevents double claims per policy, and automatically updates reputation scores. Features reentrancy protection and manual approval workflow (MVP).
Key Functions:
fileClaim(string description)- Submit accident claimapproveClaim(address worker)- Owner approves and processes payout (50,000 SHM)rejectClaim(address worker, string reason)- Owner rejects fraudulent claimsgetMyClaimStatus()- Check claim statusfundContract()- Add funds for payouts
Tracks worker safety records and calculates premium discounts. Each worker starts with 100 base points. Safe driving days add +5 points, while claims deduct -20 points. Calculates dynamic discounts (up to 20% off) for high-reputation workers and applies surcharges for risky drivers.
Scoring System:
- Base score: 100 points
- Safe day: +5 points
- Claim penalty: -20 points
- Discount tiers: 120+ (10%), 150+ (20%), <80 (10% surcharge)
IMPORTANT: Deploy in this exact order!
// Deploy first - it's independent
InsurancePolicy insurancePolicy = new InsurancePolicy();// Deploy second - needs InsurancePolicy address
ClaimPayout claimPayout = new ClaimPayout(address(insurancePolicy));// Deploy third - it's independent
ReputationScore reputationScore = new ReputationScore();// Link ReputationScore to ClaimPayout
claimPayout.setReputationContract(address(reputationScore));// Send SHM to ClaimPayout for payouts
claimPayout.fundContract{value: 500000 ether}();
// Or simply send directly to contract addressβββββββββββββββββββββββ
β InsurancePolicy β
β (Coverage Sales) β
ββββββββββββ¬βββββββββββ
β
β hasValidCoverage()
β markAsClaimed()
βΌ
βββββββββββββββββββββββ ββββββββββββββββββββ
β ClaimPayout βββββββΆβ ReputationScore β
β (Claims & Payouts) β β (Safety Tracker) β
βββββββββββββββββββββββ ββββββββββββββββββββ
β β²
β β
βββdeductForClaim()βββββββββ
Flow:
- Worker buys coverage from InsurancePolicy
- Worker files claim via ClaimPayout
- ClaimPayout checks InsurancePolicy for valid coverage
- Owner approves claim in ClaimPayout
- ClaimPayout triggers payout + updates ReputationScore
// Send 5 SHM to buy 24-hour coverage
insurancePolicy.buyDailyCoverage{value: 5 ether}();(bool isActive, uint256 coverage, uint256 timeLeft) = insurancePolicy.checkMyCoverage();
// Returns: (true, 50000 SHM, seconds remaining)claimPayout.fileClaim("Two-wheeler accident on MG Road, Bangalore at 3 PM");(ClaimStatus status, uint256 amount, uint256 filedAt, string memory notes) =
claimPayout.getMyClaimStatus();(uint256 score, uint256 safeDays, uint256 claims, int256 discount) =
reputationScore.getMyScore();
// Example: (120, 15, 1, 10) = Score 120, 15 safe days, 1 claim, 10% discount// After verifying accident occurred
claimPayout.approveClaim(workerAddress);
// This automatically:
// - Marks policy as claimed
// - Sends 50,000 SHM to worker
// - Deducts 20 reputation pointsclaimPayout.rejectClaim(workerAddress, "No evidence of accident");// Give +5 points for completing a safe day
reputationScore.addSafeDay(workerAddress);insurancePolicy.withdrawPremiums();claimPayout.fundContract{value: 1000000 ether}();// ===== DAY 1: New Driver Joins =====
// 1. Rajesh buys coverage (8 AM)
await insurancePolicy.connect(rajesh).buyDailyCoverage({value: ethers.parseEther("5")});
β
Event: PolicyPurchased
β
Coverage: 50,000 SHM until 8 AM tomorrow
β
Reputation: 100 (default)
// 2. Rajesh completes safe day (8 PM)
await reputationScore.connect(owner).addSafeDay(rajesh.address);
β
Reputation: 105 (+5)
β
Discount: 0% (still below 120)
// ===== DAY 2: Accident Happens =====
// 3. Rajesh renews coverage (8 AM)
await insurancePolicy.connect(rajesh).buyDailyCoverage({value: ethers.parseEther("5")});
β
New 24-hour coverage starts
// 4. Accident occurs! (2 PM)
await claimPayout.connect(rajesh).fileClaim("Bike accident, broken arm");
β
Event: ClaimFiled
β
Status: Pending
// 5. Owner verifies and approves (2:30 PM)
await claimPayout.connect(owner).approveClaim(rajesh.address);
β
Event: ClaimApproved
β
Event: PayoutSent
β
Rajesh receives: 50,000 SHM
β
Reputation: 85 (-20 penalty)
β
Policy marked as claimed
// ===== DAY 10: Rajesh Returns =====
// 6. After recovery, Rajesh continues working
// Owner rewards him for 7 safe days
for(let i = 0; i < 7; i++) {
await reputationScore.connect(owner).addSafeDay(rajesh.address);
}
β
Reputation: 120 (85 + 35)
β
Now qualifies for 10% discount!
// 7. Check discount
const discount = await reputationScore.calculateDiscount(rajesh.address);
console.log(discount); // Returns: 10
// 8. Buy coverage with new reputation
await insurancePolicy.connect(rajesh).buyDailyCoverage({value: ethers.parseEther("5")});
// NOTE: In V2, we'll integrate discount into buyDailyCoverage()
// For now, discount is just tracked for future use
// ===== DAY 30: Premium Driver Status =====
// 9. After 30 total safe days
// Reputation: 150+ (qualifies for 20% discount)
const premium = await reputationScore.getDiscountedPremium(
rajesh.address,
ethers.parseEther("5")
);
console.log(premium); // Returns: 4 SHM (20% off)- Coverage automatically expires after 24 hours
- No need to manually cancel
- Worker can buy new coverage anytime after expiration
- Each policy can only be claimed once
hasClaimedflag prevents fraud- Must buy new coverage to claim again
- Safe drivers get discounts (up to 20% off)
- Risky drivers pay surcharges (10% extra)
- Incentivizes safe driving behavior
- Owner verifies accidents before payout
- Future: Integrate Chainlink oracles for automation
- Prevents fraudulent claims
noReentrantmodifier on approveClaim- Prevents reentrancy attacks during payouts
- Industry-standard security pattern
β
onlyOwner modifiers on admin functions
β
Reentrancy protection on payouts
β
Double-claim prevention
β
Coverage validation before payouts
β
Balance checks before transfers
β
Timestamp-based expiration (not manually controlled)
All contracts are deployed and live on Shardeum EVM Testnet:
InsurancePolicy: 0x3A84E06554876A557b16249619247eF765C35407
ClaimPayout: 0xf678B23d7887d9c9dbc49C2170902d5c88075c2D
ReputationScore: 0x199678E7AF0B7a9f62523563f9eF861e242e944A
Network: Shardeum EVM Testnet (Mezame) | Chain ID: 8119
Explorer: https://explorer-mezame.shardeum.org
Note: Contracts are already connected. ReputationScore is linked to ClaimPayout.
Create scripts/deploy.js:
const hre = require("hardhat");
const { ethers } = require("hardhat");
async function main() {
console.log("π Deploying ParaCipher contracts...\n");
// 1. Deploy InsurancePolicy
console.log("π Deploying InsurancePolicy...");
const InsurancePolicy = await hre.ethers.getContractFactory("InsurancePolicy");
const insurancePolicy = await InsurancePolicy.deploy();
await insurancePolicy.waitForDeployment();
const insurancePolicyAddress = await insurancePolicy.getAddress();
console.log("β
InsurancePolicy deployed to:", insurancePolicyAddress);
// 2. Deploy ClaimPayout
console.log("\nπ Deploying ClaimPayout...");
const ClaimPayout = await hre.ethers.getContractFactory("ClaimPayout");
const claimPayout = await ClaimPayout.deploy(insurancePolicyAddress);
await claimPayout.waitForDeployment();
const claimPayoutAddress = await claimPayout.getAddress();
console.log("β
ClaimPayout deployed to:", claimPayoutAddress);
// 3. Deploy ReputationScore
console.log("\nπ Deploying ReputationScore...");
const ReputationScore = await hre.ethers.getContractFactory("ReputationScore");
const reputationScore = await ReputationScore.deploy();
await reputationScore.waitForDeployment();
const reputationScoreAddress = await reputationScore.getAddress();
console.log("β
ReputationScore deployed to:", reputationScoreAddress);
// 4. Connect contracts
console.log("\nπ Connecting contracts...");
const tx = await claimPayout.setReputationContract(reputationScoreAddress);
await tx.wait();
console.log("β
ReputationScore linked to ClaimPayout");
// 5. Fund ClaimPayout
console.log("\nπ° Funding ClaimPayout with 500,000 SHM...");
const fundTx = await claimPayout.fundContract({
value: ethers.parseEther("500000")
});
await fundTx.wait();
console.log("β
ClaimPayout funded");
// Summary
console.log("\n" + "=".repeat(50));
console.log("π DEPLOYMENT COMPLETE!");
console.log("=".repeat(50));
console.log("\nContract Addresses:");
console.log("InsurancePolicy: ", insurancePolicyAddress);
console.log("ClaimPayout: ", claimPayoutAddress);
console.log("ReputationScore: ", reputationScoreAddress);
console.log("\n⨠Ready for testing!");
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});Run with:
# For Shardeum Testnet
npx hardhat run scripts/deploy.js --network shardeum
# Or for local testing
npx hardhat run scripts/deploy.js --network localhostNote: Contracts are already deployed on Shardeum Testnet. See contract addresses above.
Create test/ParaCipher.test.js:
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("ParaCipher E2E Test", function() {
let insurancePolicy, claimPayout, reputationScore;
let owner, worker1;
beforeEach(async function() {
[owner, worker1] = await ethers.getSigners();
// Deploy contracts
const InsurancePolicy = await ethers.getContractFactory("InsurancePolicy");
insurancePolicy = await InsurancePolicy.deploy();
const ClaimPayout = await ethers.getContractFactory("ClaimPayout");
claimPayout = await ClaimPayout.deploy(await insurancePolicy.getAddress());
const ReputationScore = await ethers.getContractFactory("ReputationScore");
reputationScore = await ReputationScore.deploy();
// Connect contracts
await claimPayout.setReputationContract(await reputationScore.getAddress());
// Fund ClaimPayout
await claimPayout.fundContract({value: ethers.parseEther("100000")});
});
it("Full flow: Buy coverage β File claim β Get payout", async function() {
// 1. Worker buys coverage
await insurancePolicy.connect(worker1).buyDailyCoverage({
value: ethers.parseEther("5")
});
// 2. Check coverage is active
const [isActive, coverage] = await insurancePolicy.connect(worker1).checkMyCoverage();
expect(isActive).to.be.true;
expect(coverage).to.equal(ethers.parseEther("50000"));
// 3. File claim
await claimPayout.connect(worker1).fileClaim("Test accident");
// 4. Check claim is pending
const [status] = await claimPayout.connect(worker1).getMyClaimStatus();
expect(status).to.equal(1); // Pending
// 5. Owner approves claim
const balanceBefore = await ethers.provider.getBalance(worker1.address);
await claimPayout.connect(owner).approveClaim(worker1.address);
// 6. Verify payout received
const balanceAfter = await ethers.provider.getBalance(worker1.address);
expect(balanceAfter - balanceBefore).to.equal(ethers.parseEther("50000"));
// 7. Check reputation decreased
const [score] = await reputationScore.connect(worker1).getMyScore();
expect(score).to.equal(80); // 100 - 20 penalty
});
});Run tests:
npx hardhat test// Connect to contracts
const insurancePolicy = new ethers.Contract(POLICY_ADDRESS, POLICY_ABI, signer);
const claimPayout = new ethers.Contract(CLAIM_ADDRESS, CLAIM_ABI, signer);
const reputationScore = new ethers.Contract(REP_ADDRESS, REP_ABI, signer);
// Buy coverage button click
async function buyCoverage() {
try {
const tx = await insurancePolicy.buyDailyCoverage({
value: ethers.parseEther("5")
});
await tx.wait();
alert("Coverage purchased! You're covered for 24 hours.");
} catch (error) {
alert("Error: " + error.message);
}
}
// File claim button click
async function fileClaim(description) {
try {
const tx = await claimPayout.fileClaim(description);
await tx.wait();
alert("Claim filed! Waiting for approval.");
} catch (error) {
alert("Error: " + error.message);
}
}
// Check my dashboard
async function loadDashboard() {
// Get coverage status
const [isActive, coverage, timeLeft] = await insurancePolicy.checkMyCoverage();
// Get reputation
const [score, safeDays, claims, discount] = await reputationScore.getMyScore();
// Get claim status
const [claimStatus] = await claimPayout.getMyClaimStatus();
// Update UI
document.getElementById("coverage").innerText = isActive ? "Active" : "Inactive";
document.getElementById("score").innerText = score;
document.getElementById("discount").innerText = discount + "%";
}-
Chainlink Oracle Integration
- Automate claim verification
- Connect to accident databases
- Remove manual approval
-
Dynamic Pricing
- Integrate reputation discounts into buyDailyCoverage
- Real-time premium calculation
-
NFT Policies
- Mint ERC721 tokens as policy certificates
- Tradeable policies
-
Multi-tier Coverage
- βΉ50K, βΉ100K, βΉ200K coverage options
- Different premium tiers
-
Automated Reputation Tracking
- Daily automated safe day rewards
- No manual admin intervention
Built by Team Cipher Labs