KneeDeep

AI agents pay per query for live Mumbai flood reports from verified humans; reporters get paid.

KneeDeep

Created At

ETHGlobal Mumbai

Project Description

During Mumbai's monsoon, a delivery rider can lose an hour—or a vehicle—to a flooded subway that no weather API knows about. Weather data tells an agent it rained. It doesn't tell the agent whether a particular street is passable right now.

KneeDeep is a paid, real-time API for street-level flood conditions, powered by human reports and built for AI agents.

  • People verify their uniqueness through World ID and report conditions using five levels: dry, ankle, knee, waist, or road closed. Reports and votes are stored on Arkiv with a three-hour expiry because street conditions change quickly.
  • AI agents call GET /v1/conditions. The endpoint returns HTTP 402, allowing agents to pay 0.1 HBAR per query through x402 on Hedera, using their own account. Responses include the condition, confidence, supporting evidence, and a vehicle passability verdict: safe, risky, blocked, or unknown.
  • Our fusion engine combines independent reports, accounts for recency and disputes, and never treats missing data as safe. A safe verdict requires corroboration from at least two independent people.
  • A dispatch agent checks six checkpoints across two routes, pays for the required queries, and chooses the safer route—or holds the delivery if all routes are blocked.
  • 70% of eligible query revenue is allocated to contributors whose reports were corroborated by other verified people.
  • A Chainlink CRE workflow independently recomputes conditions from public Arkiv evidence and publishes an attestation on Sepolia. The API exposes whether its results match the attestation.

The demo runs on testnets and uses clearly labelled simulated scenarios. The CRE demonstration uses the simulator's trusted-sender configuration; production DON signature verification is a separate deployment step.

How it's Made

KneeDeep is a TypeScript monorepo consisting of a NestJS API, PostgreSQL database, Vite + React + Leaflet frontend, standalone dispatch agent, and Chainlink CRE workflow with a Foundry smart contract. A single Docker image runs on Render, with the API serving the web application.

Hedera + x402: The paid conditions endpoint uses @x402/express and @x402/hedera, with the Blocky402 facilitator. The agent signs HBAR payments from its own account using @x402/fetch, with per-query and per-trip spending caps. Invalid requests are not charged. Eligible reporter earnings are paid through the Hiero SDK using batched transfers. Database reservations, pre-generated transaction IDs, advisory locks, and Mirror Node reconciliation protect against duplicate payouts after failures.

Arkiv: Reports and votes are public entities with native TTLs. Votes expire with their associated reports, so evidence expiration is handled by the data layer rather than a cleanup cron job. Agents and independent workflows can inspect the underlying evidence without relying on KneeDeep's API.

World ID: IDKit Proof of Human is used to limit duplicate reporter identities. The relying-party request is signed server-side, legacy proofs are rejected, and the public reporter ID is derived from a salted nullifier hash. The nullifier itself is not stored.

Fusion engine: A deterministic, dependency-free function combines reports and votes. Evidence recency decays with a 45-minute half-life, each human counts once, corroboration follows 1 − 0.5^n, and disputes count against a reported level. Ties resolve toward the more severe condition because routing decisions are safety-critical.

Chainlink CRE: The same fusion logic is compiled into the CRE workflow. Each workflow node reads public Arkiv JSON-RPC data and recomputes area conditions for a shared scheduled timestamp. CRE consensus requires identical canonical results before publishing an attestation to the Sepolia contract. The API compares its condition results against the latest attestation. The current demonstration uses the CRE simulation forwarder with a trusted-sender restriction; production deployment would use the signature-verifying Keystone Forwarder.

Engineering challenges:

  • Identified and fixed a simulation-forwarder trust issue that could have allowed unauthorized attestations.
  • Used PostgreSQL advisory locks and reservation rows to enforce one report per person per cell per 30 minutes despite slow Arkiv writes.
  • Cross-checks agent trip records against the server's settled-payment ledger.

127 tests across the API, agent, contract, and workflow.

background image mobile

Join the mailing list

Get the latest news and updates