MultiHopper Build & Route Challenge
A policy gate between what an AI agent wants to pay and what it is allowed to pay. Budget rules live outside the model; routing and signing happen on Solana through MultiHopper; the ledger records everything.
Giving an agent a wallet is easy. Giving it a wallet it cannot misuse is not.
Either a human approves every transfer, so the agent is a script with extra steps, or the agent holds the key and one bad prompt drains the treasury.
Programmable, compliance-screened multi-hop routing. It makes the route a product decision. It does not decide who may spend what.
Per-transaction and daily limits, recipient allowlists and an approval band, evaluated as a pure function before any network call, with the reason returned every time.
One intent in, one routed transfer out, with the decision attached to it.
Numbers below come from live runs of this code against devnet.multihopper.com/api/v1. Devnet and mainnet are separate deployments, so they do not count as production volume.
| Check | Result |
|---|---|
npm test | 34 passed |
| Product run, 0.1 SOL over 3 hops | transfer 1738 · completed |
| Quote accuracy | 99502487 lamports delivered |
| Integrator share, per route | 248756 lamports |
| Credited across completed routes | 995024 lamports · 4 payouts |
| On-chain settlement | finalized · no errors |
A three-hop devnet route reaches its terminal status in about five minutes and moves through processing, active then completed.
Small surface, typed end to end, and the reasons travel with the decision.
// POST /spend { "agentId": "research-agent", "recipient": "<pubkey>", "amountUsd": 40, "amountRaw": "100000000", "memo": "compute credits for 200 research tasks" } // 200 { "decision": { "outcome": "approved", "reasons": ["within per-transaction and daily limits"] }, "transfer": { "id": 1738, "status": "processing" }, "signatures": ["5miGBFNN...", "435o9rzw..."] }
Batch payouts reuse the same path: one route pays up to 20 wallets, and hops dominate cost, so extra destinations are nearly free.
The published docs and the running service disagree in a few places. Each difference is handled here and pinned with a regression test.
POST /transfers answers BAD_REQUEST: amountTokens: Required even though it reads as optional. Derived from the raw amount and decimals.
Every mutation needs the header, prepare included, or the API answers MH_070.
Declaring JSON with no body is refused by the API's Fastify layer, which is exactly what prepare looks like.
confirm-broadcast demands routeInitSignatures even in the first call, so the documented split confirmation fails.
create returns the transfer flat, prepare wraps it, and routeInitTxs arrives as { base64 } objects. Normalised at the client.
orchestratorInitTx arrives as a versioned v0 message although the docs promise a legacy transaction.
cp .env.example .env # MH_API_KEY, TREASURY_KEYPAIR_B58, MH_WEBHOOK_SECRET npm install npm run typecheck npm test RECIPIENT=<devnet-pubkey> npm run demo # policy → estimate → routed transfer npm run dev # agent HTTP API on :8787
TypeScript Solana MultiHopper API v1 key custody local CI green MIT