How the pieces fit together.
examples/agent.ts.Morpho (Ethereum mainnet) Robinhood Chain testnet (46630)
┌───────────────────┐ ┌────────────────────────┐
│ User positions │ │ VetoricaCredit │
│ (custody) │ │ mintFromYield/spendFrom│
└────────┬──────────┘ └──────────▲─────────────┘
│ GraphQL api.morpho.org │ viem
┌────────▼──────────────────────────────────┴──────────┐
│ backend, yield reader + agent registry + indexer │
└──────────────────────────▲───────────────────────────┘
dApp (Next.js + wagmi)Authenticate with the agent's API key (returned once at creation):
curl -X POST $API/agents/1/spend \
-H "X-Agent-Key: vtr_..." \
-H "Content-Type: application/json" \
-d '{"amountUsd": 2.5, "action": "inference"}'Spends are checked against the agent's budget and maxSpendUsdguardrail, then burned on-chain via spendFrom.
| POST /auth/nonce · /auth/verify | wallet login → bearer token |
| GET /credits/:address | balance + reports + indexed events |
| POST /users/:address/track | start yield tracking (authed) |
| GET /users/:address/positions | live Morpho positions |
| POST/GET/PATCH /agents… | agent CRUD + budget guardrails |
| POST /agents/:id/spend | on-chain debit (owner or API key) |
| GET /agents/:id/usage | spend history |
| Credits | Robinhood Chain Testnet · chain ID 46630 · ETH gas |
| Deposits (Morpho) | Ethereum mainnet · chain ID 1 |
| Morpho API | api.morpho.org/graphql |