Why agents need wallets
Every autonomous agent hits the same problem: it needs to pay for things. A research bot needs Serper API credits. A content agent needs image generation tokens. An outreach agent needs email delivery.
The current options are terrible. Hardcoding your credit card into a prompt is a security nightmare. Building a custom billing layer takes months. Human-in-the-loop approvals defeat the point of autonomous agents.
What you're building: A programmable wallet for your AI agent. Budget limits enforced automatically. Transaction history for auditing. Simple REST API for integration.
This tutorial uses the Trove Wallet SDK — five endpoints, no dependencies beyond Node.js, deployed on your own infrastructure.
What you need
Before we start, make sure you have:
- Node.js 18+ — installed on your machine
- npm — comes with Node
- A Trove instance — we'll create the API key in Step 1
That's it. No Stripe account, no crypto wallet, no credit card. Just a running Trove instance.
Every wallet needs an API key to authenticate. Create one with a simple POST request:
The key starts with tvpk_ — that's how you'll identify it in requests. Keep this key secret. It authenticates all wallet operations.
Now create a wallet for your agent. You define the agent ID, a friendly name, and most importantly — a budget limit that Trove enforces automatically.
Budget enforcement: Every purchase is checked against remaining_budget before approval. If the purchase would exceed the limit, it's rejected. No surprises on your bill.
Now your agent can make purchases. Each purchase records the amount, description, and vendor — all automatically deducted from the budget.
The purchase is approved because $5 is well under the $50 budget. Let's make another one to see the budget deduction in action:
At any time, check how much budget remains. This is the endpoint your monitoring systems call.
$17.50 spent, $32.50 remaining. The wallet tracks every penny.
For auditing and reporting, fetch the complete transaction history with pagination.
Transactions are returned newest-first. Use limit and offset for paginated access to large histories.
What's next
You've got the basics working. Here are the features that take this from "proof of concept" to production:
Spending rules
Add per-vendor limits, time-based restrictions (no spending outside business hours), or require approval for purchases over a threshold. Rules are evaluated before every purchase.
Analytics dashboard
See spending by vendor, by agent, over time. Identify which agents are costliest and where you can optimize.
Multi-agent wallets
Create parent-child wallet hierarchies. A "team" wallet funds individual agent wallets with their own limits. Roll up spend into one bill.
Webhook notifications
Get notified on every purchase, or only when budgets hit thresholds. Integrate with your existing monitoring stack.
All of this is in the full API reference. Go deeper on spending rules, webhook configuration, and multi-wallet hierarchies.
Ready to give your agents wallets?
Start with the full API docs or join the waitlist for the hosted version.