Inspiration

Every year, over $30 billion in global humanitarian aid is deployed to combat famine, climate displacement, and conflict zones. Yet, according to reports by the United Nations and transparency watchdogs, between 20% and 30% of relief funds fail to reach intended beneficiaries due to ghost distribution manifests, cargo diversion, weighbridge tampering, and bureaucratic leakage.

When donors give during crises, their money vanishes into a black box of opaque intermediary bank accounts. Conversely, legitimate frontline NGOs often face delayed funding due to slow, manual auditing processes.

I asked myself: What if aid wasn’t paid upfront on blind faith, and what if release wasn't bottlenecked by manual paperwork? What if capital was locked in immutable smart contract escrows on Polygon and released tranche-by-tranche only when an intelligent, multimodal AI forensic vision engine cryptographically confirmed that the physical supplies arrived on the ground?

That vision inspired AidChain — the world’s first autonomous, AI-audited humanitarian aid distribution protocol on Polygon Amoy.

What It Does

AidChain replaces traditional humanitarian aid grants with programmable, milestone-based escrow vaults governed by cryptographic multi-sig contracts and real-time multimodal AI verification:

  1. Milestone Escrow Vaults (AidVault.sol): Donors contribute USDC or POL into dedicated smart contract vaults deployed on Polygon Amoy. Funds are never disbursed in a single lump sum. Instead, capital is partitioned into milestone tranches (e.g., Milestone 1: 50 Metric Tons Grain Procured, Milestone 2: Convoy Transit to Turkana, Milestone 3: Last-Mile Biometric Beneficiary Handover).
  2. Field Verification & Pinata IPFS Dropzone: On-site field verifiers capture tamper seal photographs, weighbridge manifests, bill of lading receipts, and GPS camera tags. These proofs are permanently pinned to Pinata IPFS, producing an immutable cryptographic CID.
  3. Aids AI Multimodal Forensic Oracle: My custom multimodal vision pipeline evaluates the physical evidence images against official manifests. The model inspects:
  4. Tamper Seal Integrity: Detects hairline fractures, unauthorized clip removals, and serial mismatches.
  5. Weighbridge Mathematical Audit: Calculates cargo net weight discrepancies against tare weights.
  6. EXIF & Geofence Validation: Verifies GPS coordinates against pre-defined orbital geofences.
  7. Automated Multi-Sig Release or Emergency Dispute:
  8. If the composite audit confidence exceeds the threshold $\mathcal{S}_{\text{composite}} \ge 0.92$, Aids AI attests to Polygon Amoy, satisfying the 2-of-3 multi-sig requirement and instantly releasing the tranche directly to the NGO.
  9. If anomalies or broken seals are detected, the protocol automatically freezes the escrow vault in a Disputed State, alerts the donor, and prevents capital drain.
  10. Interactive Crisis Telemetry & Live Mapbox Exploration: An East Africa satellite telemetry map with 25km orbital geofences, real-time Chainlink POL/USD conversion rates, and instant donor portfolio oversight.

Mathematical Formulation of Aid Release

AidChain models fraud detection as a constrained multi-factor optimization problem:

\($$\mathcal{S}{\text{composite}} = w_1 \mathcal{S}{\text{seal}} + w_2 \mathcal{S}{\text{manifest}} + w_3 \mathcal{S}{\text{geofence}} + w_4 \mathcal{S}_{\text{exif}}$$\)

Where weights satisfy: $$\sum_{i=1}^{4} w_i = 1.0 \quad \text{with} \quad w_1 = 0.35, \, w_2 = 0.30, \, w_3 = 0.20, \, w_4 = 0.15$$

The weighbridge verification enforces a strict physical mass conservation inequality:

$$\Delta m = \frac{|m_{\text{origin}} - m_{\text{received}}|}{m_{\text{origin}}} \le \epsilon_{\text{transit}}$$

Where $\epsilon_{\text{transit}} = 0.025$ (2.5% maximum allowable transit moisture/dust loss). If $\Delta m > \epsilon_{\text{transit}}$, the manifest score degrades exponentially:

$$\mathcal{S}{\text{manifest}} = \exp\left( -k \cdot (\Delta m - \epsilon{\text{transit}}) \right)$$

Smart contract disbursement is executed if and only if:

$$\text{State}(\text{Vault}) = \begin{cases} \text{RELEASE}, & \text{if } \mathcal{S}{\text{composite}} \ge \theta{\text{threshold}} \; (\theta = 0.92) \ \text{FROZEN}, & \text{if } \mathcal{S}{\text{composite}} < \theta{\text{threshold}} \end{cases}$$

How We Built It

AidChain is architected as an end-to-end, full-stack Web3 application with hybrid Web2/Web3 onboarding:

Smart Contracts & Blockchain:

  • Polygon Amoy Testnet (Chain ID: 80002): Low gas fees (<$0.001) and sub-2-second finality make high-frequency tranche releases viable.
  • Alchemy Supernode: High-throughput JSON-RPC communication querying real-time block heights, contract balances, and gas estimations.
  • Chainlink Decentralized Oracles: Reads POL/USD price feed aggregator (0x001382149eBa344104341c715722402d33934488) via Alchemy to calculate real-time fiat-equivalent funding.

Artificial Intelligence Engine (Aids AI):

  • Powered by @google/generative-ai multimodal vision models.
  • Custom system prompt engineered with zero-shot forensic vision heuristics for cargo packaging inspection, OCR manifest verification, and structural seal defect classification.
  • Interactive 24/7 Aids AI Audit Copilot providing streaming natural-language assistance and cryptographic transaction walkthroughs.

Decentralized Storage & Real-Time Backend:

  • Pinata Cloud (IPFS): Immutable distributed pinning for heavy media, delivery photos, and JSON audit receipts.
  • Supabase PostgreSQL: Real-time database with Row-Level Security (RLS) synchronizing milestone progress, donor transactions, and proof records.
  • Clerk Authentication: Seamless hybrid authentication allowing non-crypto donors to sign in via email/SSO while linking non-custodial Web3 Polygon wallets.
  • Resend Email Service: Real-time transactional emails dispatching cryptographic donor receipts and milestone release notifications with Polygonscan verification links.

Frontend & UX Aesthetics:

  • Next.js 16.3.5 (Turbopack) & React 19: App Router architecture with server components for sub-second page loads.
  • Tailwind CSS & Framer Motion: Bespoke warm ivory/cream (#faf6ee) light theme and matte slate-charcoal (#141a17) dark theme, tactile Emil Kowalski spring animations, and responsive scroll-driven fading effects.
  • Mapbox GL: Multi-style satellite terrain rendering (Satellite Streets, Tactical Night, Topographic Terrain) with live pulsing radar pins and 25km crisis geofences.

Challenges I Ran Into

  1. Bridging Physical Evidence with Cryptographic Truth: The hardest problem in blockchain is the "Oracle Problem" — how do you ensure an off-chain photograph represents reality? Anyone could attempt to upload a recycled delivery photo from a past year. I addressed this by enforcing a fmy-layer check: extracting raw EXIF hardware camera metadata, checking temporal consistency with on-chain timestamps, matching geographical coordinates against polygon geofences, and computing image perceptual hashes to prevent proof recycling.

  2. Fine-Tuning Physical Cargo Tolerances: Early in testing, legitimate grain convoys in Kenya were getting flagged as fraudulent because bulk trucks naturally lose 1% to 2% weight from dust blow-off and evaporation over a 400-mile desert trek. I refined my loss function so that Aids AI differentiates expected thermodynamic shrinkage from deliberate cargo diversion (>10% drop).

  3. Mapbox WebGL Canvas Hydration in Turbopack: During Next.js page transitions between / and /explore, WebGL contexts occasionally lost their bounding dimensions before DOM painting completed. I resolved this by engineering a multi-stage resize orchestrator (150ms, 600ms, 1500ms) with clean unmount teardowns, ensuring buttery smooth map rendering on all viewports.

  4. Multi-Sig Oracle Synchronization: Orchestrating a 2-of-3 multi-sig release between an automated AI oracle and a field agent required bulletproof error handling. If an AI API rate limit was hit, the escrow state could get stuck. I built idempotent retry queues and Supabase optimistic locks so no transaction is ever duplicated or lost.

Accomplishments That I am Proud Of

End-to-End Operational Lifecycle: Built a complete working platform where a user can donate, an NGO can deploy a crisis project, a field agent can upload proof to IPFS, Aids AI audits the images in under 3 seconds, and the smart contract releases funds on Polygon Amoy. Interactive Fraud Simulator: Created a live simulation mode allowing judges, donors, and auditors to test broken tamper seals and witness Aids AI freeze an escrow vault in real time. Zero Cliché, World-Class Aesthetics: Crafted an intentional, high-contrast design system that feels like a multi-million dollar institutional platform rather than a generic hackathon prototype. 100% Green Build: All 16 routes, API endpoints, and SVG/ICO icon pipelines compile cleanly with 0 warnings or errors in Next.js 16 Turbopack.

What I Learned

Multimodal AI as the Ultimate Web3 Oracle: Vision LLMs have reached the maturity level where they can perform forensic analysis that previously required costly manual third-party inspection firms. Trust Requires Visual Proof: Donors don't just want a transaction hash; they want to see the sealed container, read the weighbridge receipt, and inspect the satellite coordinates. Visual transparency increases donation conversion exponentially. Hybrid Web2/Web3 is Mandatory for Real-World Impact: Field agents in remote counties cannot be forced to manage complex seed phrases. By combining Clerk email auth with Polygon smart contract escrows, I created an interface accessible to anyone with a smartphone.

What's Next for AidChain

Hardware IoT Smart Bolts: Direct integration with Bluetooth/LoRaWAN tamper-evident electronic seals that transmit cryptographic opening logs directly to my smart contracts. ERC-4337 Account Abstraction: Implementing paymasters so on-site verifiers can sign milestone proofs without holding POL for gas fees. Autonomous Drone & Satellite Verification: Integrating satellite radar feeds (Synthetic Aperture Radar) to cross-reference convoy arrival timestamps with physical warehouse movements. Mainnet Deployment: Migrating from Polygon Amoy to Polygon zkEVM / PoS Mainnet for live humanitarian missions in East Africa.

Built With

Share this project:

Updates

Submission history