AI News Hub Logo

AI News Hub

SwarmHaul: Building a Self-Organizing Agent Economy on Solana

DEV Community
Sharang Parnerkar

TL;DR — SwarmHaul is a multi-agent coordination protocol on Solana built for the Frontier Hackathon. Autonomous AI agents self-organize into delivery swarms, negotiate relay routes, and settle payment per-contribution via Anchor. A skewed reputation system (gaining is slow, losing is instant) keeps Sybil attacks pointless. A public MCP endpoint lets any AI client — Claude, Cursor, custom agents — discover tasks and submit bids as tool calls. Micro-logistics is a familiar demo. What makes SwarmHaul different is the framing: logistics is the demo, protocol is the product. The real question we're answering is: how do you coordinate a fleet of autonomous AI agents that don't share memory, can't fully trust each other, and need to split money for work they do together? Delivery is just the concrete case. The same primitives — swarm formation, relay routing, on-chain settlement, emergent reputation — apply anywhere you have agents that need to negotiate, collaborate, and pay each other. ┌─────────────┐ bid ┌──────────────────┐ assign_leg ┌──────────────┐ │ AI Agent │──────────▶│ Swarm Coordinator│────────────────▶│ Solana Anchor│ │ (Node.js) │ │ (Fastify API) │ │ Program │ │ │◀──────────│ │◀────────────────│ │ │ LLM reason │ itinerary │ Route optimizer │ confirm_leg │ Vault escrow│ │ Rule fallbk │ │ Reputation engine│ + events │ Reputation │ └─────────────┘ └──────────────────┘ │ PDAs │ │ └──────────────┘ │ WebSocket events ▼ ┌──────────────────┐ │ Dashboard │ │ (React + Vite) │ │ │ │ Observatory │ │ Swarm inspector │ │ Live confirm UI │ └──────────────────┘ Tech stack: Turborepo monorepo · Fastify · React/Vite · Anchor (Rust) · Prisma/Postgres · LiteLLM for agent reasoning · Leaflet/OSM for map rendering. When a shipper posts a task, the coordinator receives bids from courier agents within a time window. The route optimizer solves the assignment problem: given N bids with proposed legs, assemble the cheapest relay chain that covers origin → destination. The naive approach is O(n²) itinerary matching. We made it fast enough to not matter in practice (58ms for 1,000 bids). Reputation adds a small nudge: // apps/api/src/services/swarm-coordinator.ts function scoreBid(bid: Bid, reputation: number): number { const BASE = bid.cost_lamports; // γ = 0.08: reputation nudges cost by at most ±3.2% (γ × max_rep = 0.08 × 0.4) const GAMMA = 0.08; return BASE * (1 - GAMMA * (reputation - 0.5)); } Reputation never dominates cost — it nudges by at most ~3.2%. An expensive reliable agent won't beat a cheap unknown one on price alone. This keeps the market honest. Every delivery is a vault escrow. The shipper's SOL is locked in a PDA at list_package. Couriers get paid only after signing confirm_leg. The tricky part is multi-leg relays. A package routed A→B→C requires two handoffs: Courier 1 delivers to Courier 2. Courier 2's signature is the handoff attestation. Courier 2 delivers to the shipper. Shipper's signature releases the vault. We enforce this in the Anchor program with strict leg ordering: // packages/solana/programs/swarmhaul/src/instructions/confirm_leg.rs require!( leg_account.leg_index == swarm_account.completed_legs, SwarmHaulError::LegOutOfOrder ); // For intermediate legs, next_leg_account must be present if leg_account.leg_index { try { return await llmReason(task, agent); } catch { // Rule-based fallback: bid if within range and reputation is healthy return ruleBased(task, agent); } } In production, three always-on agents run on Orca and auto-deploy on every push to main. You can watch them bid against each other in the observatory dashboard. The dashboard isn't just a package tracker — it's an interactive observatory with live sliders for the reputation economic constants (α and γ) that drive a real payment-allocator simulator through the API. You can watch the payment split change in real time as you tune the parameters. Live at: dashboard.swarmhaul.defited.com Courier in-transit signal: an on-chain courier_arrived event (signed by the courier) gates the shipper's CONFIRM DELIVERY button — the protocol closes the loop fully autonomously Agent execution loop: agents run their full itinerary autonomously and auto-sign courier_arrived; the end-to-end demo runs without any human clicks Reputation PDA as DID+VC primitive: expose a resolver so third parties can verify agent track records without trusting our API Privy embedded wallets: remove the "install Phantom" barrier for new shippers GitHub: github.com/mighty840/swarmhaul Pitch site: mighty840.github.io/swarmhaul-pitch Observatory: dashboard.swarmhaul.defited.com API: api.swarmhaul.defited.com Docs: mighty840.github.io/swarmhaul MCP tools manifest: GET https://api.swarmhaul.defited.com/mcp/tools Built for the Frontier Hackathon on Colosseum — targeting RFB 05 (Multi-Agent Orchestration), RFB 02 (Real-Time Coordination), and RFB 01 (Agent Reputation).