Agent Spending Controls
Non-custodial policy layer for AI agent wallets
Give your AI agents the ability to make payments whilst enforcing spending limitsβwithout custodying keys.
The Problem
AI agents need to make autonomous payments, but developers face a dilemma:
- Give agents direct wallet access β Risk of runaway spending, no oversight, compliance gaps
- Use custodial solutions β Liability, trust issues, regulatory complications
- Build custom controls β Weeks of engineering, security risks, maintenance burden
We solve this: A non-custodial policy layer that wraps any wallet SDK, enforcing spending limits without ever touching your keys.
Live Demo
Real-time monitoring of multiple agents with different spending policies
*Detailed β¦
Agent Spending Controls
Non-custodial policy layer for AI agent wallets
Give your AI agents the ability to make payments whilst enforcing spending limitsβwithout custodying keys.
The Problem
AI agents need to make autonomous payments, but developers face a dilemma:
- Give agents direct wallet access β Risk of runaway spending, no oversight, compliance gaps
- Use custodial solutions β Liability, trust issues, regulatory complications
- Build custom controls β Weeks of engineering, security risks, maintenance burden
We solve this: A non-custodial policy layer that wraps any wallet SDK, enforcing spending limits without ever touching your keys.
Live Demo
Real-time monitoring of multiple agents with different spending policies
Detailed audit trail showing ALLOWED and BLOCKED transactions
Quick Start
1. Clone and Install
git clone https://github.com/L1AD/agent-spending-controls.git
cd agent-spending-controls
npm install
2. Start the Policy API
npm run api
Runs on http://localhost:3001
3. Start the Dashboard (in a new terminal)
npm run dashboard
Open http://localhost:3002
to see real-time monitoring.
4. Run the Demo (in a new terminal)
npm run demo
β οΈ POC Mode: This demo runs in dry-run mode and does not execute real blockchain transactions. Policy enforcement (Gates 1 & 2) runs completely, but blockchain execution is simulated to avoid needing funded wallets. This demonstrates the policy layer without requiring gas fees.
This demonstrates:
- π€ 3 agents with different spending limits (conservative, moderate, generous)
- β Transactions being ALLOWED based on policy
- β Transactions being BLOCKED when limits exceeded
- π Real-time counter tracking and dashboard updates
- π Two-gate enforcement with tamper protection
- πΈ Simulated transaction execution (real blockchain code available but commented out)
How It Works
Two-Gate Enforcement Model
Developer Code
β
β wallet.send(intent)
βΌ
ββββββββββββββββββββββββββββββββββββββββββ
β Policy SDK (Your Machine) β
β β
β πͺ GATE 1: Validate Intent β βββ Check policy, issue token
β πͺ GATE 2: Verify Authorisation β βββ Verify token, consume it
β π WDK: Sign & Broadcast β βββ You keep the keys
ββββββββββββββββββββββββββββββββββββββββββ
β
ββββΊ Blockchain
Key Security Features:
- β Intent Fingerprinting - Tamper detection via SHA-256 hashing
- β Single-Use Tokens - JWT tokens with 60-second TTL, consumed on first use
- β Immediate Reservation - Amount reserved at Gate 1, preventing race conditions
- β Non-Custodial - Your keys never leave your infrastructure
Developer Integration
Instead of using a wallet SDK directly:
// β Direct WDK (no policy enforcement)
const wdk = new WDK(seedPhrase);
const account = await wdk.getAccount('ethereum', 0);
await account.sendTransaction({ to: '0x...', value: parseEther('1.0') });
Wrap it with our policy layer:
// β
With spending controls
import { PolicyWallet, PolicyError } from 'agent-spending-controls';
const wallet = new PolicyWallet(wdk, {
apiUrl: 'http://localhost:3001',
orgId: 'your-org',
walletId: 'your-wallet',
agentId: 'agent-1'
});
try {
await wallet.send({
chain: 'ethereum',
asset: 'eth',
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1',
amount: '1000000000000000000' // 1 ETH
});
console.log('β
Payment approved and executed');
} catch (error) {
if (error instanceof PolicyError) {
console.log(`β Blocked: ${error.message}`);
console.log(` Code: ${error.code}`);
console.log(` Remaining today: ${error.details.counters.remainingDaily} ETH`);
}
}
Features
β Currently Implemented (Phase 1 - POC)
Feature | Description |
---|---|
Per-Transaction Limits | Maximum amount per single transaction |
Daily Limits | Maximum total spending per 24-hour period (midnight reset) |
Hourly Limits | Maximum total spending per hour (UTC hour boundaries) |
Recipient Whitelist | Only allow transactions to pre-approved addresses |
Transaction Frequency | Maximum X transactions per time period (e.g., 3 per hour) |
Multi-Agent Management | Different limits for each agent |
Real-Time Monitoring | Live dashboard with auto-refresh |
Audit Trail | Append-only log of every policy decision |
Tamper Protection | Intent fingerprinting prevents modification |
Single-Use Authorisations | Tokens consumed on first verification |
Ethereum Support | Native ETH and ERC-20 tokens |
π Planned (See POLICY_CONTROLS.md for full list)
- Time-Based Limits - Weekly, monthly caps
- Velocity Controls - Cooldown periods, burst protection
- Recipient Controls - Blacklists, address screening
- Multi-Chain - Bitcoin, Solana, Polygon, Arbitrum, etc.
- Approval Workflows - Two-person rule, supervisor approval for large amounts
- Fraud Detection - Anomaly detection, behavioural analysis
- Compliance - KYC/AML integration, sanctions screening, reporting
Want to contribute? See 100+ potential controls and pick one to implement!
Architecture
Project Structure
agent-spending-controls/
βββ src/
β βββ api/ # Policy enforcement API
β β βββ server.ts # Express server (port 3001)
β β βββ policy-engine.ts # Spending limit evaluation
β β βββ validate.ts # Gate 1: Validate intent
β β βββ verify.ts # Gate 2: Verify authorisation
β β βββ auth.ts # JWT token management
β β βββ storage.ts # In-memory data store
β β βββ types.ts # API type definitions
β β
β βββ sdk/ # Client-side SDK
β β βββ policy-wallet.ts # Wrapper around wallet SDKs
β β βββ types.ts # SDK types and PolicyError
β β βββ index.ts # Public exports
β β
β βββ dashboard/ # Real-time monitoring UI
β βββ server.ts # Dashboard server (port 3002)
β βββ public/
β βββ index.html # Auto-refreshing UI
β
βββ examples/
β βββ multi-agent-demo.ts # 3 agents with different limits
β
βββ docs/
β βββ POLICY_CONTROLS.md # 100+ potential policy controls
β βββ images/ # Screenshots
β
βββ ARCHITECTURE.md # Detailed technical documentation
βββ CONTRIBUTING.md # How to contribute
Data Flow
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Agent calls wallet.send(intent) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. SDK β POST /validate-intent β
β β’ Policy engine evaluates spending limits β
β β’ Immediately reserves amount in daily counter β
β β’ Issues JWT token with intent fingerprint β
β β’ Returns: { decision: 'allow', auth: 'token...', ... } β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. SDK β POST /verify-authorisation β
β β’ Verifies JWT signature and expiry (60s TTL) β
β β’ Checks token hasn't been used before β
β β’ Validates intent fingerprint matches (tamper check) β
β β’ Marks token as consumed (single-use) β
β β’ Returns: { status: 'valid' } β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 4. SDK β WDK.sign() β Broadcast to blockchain β
β β’ Developer's keys sign the transaction β
β β’ Transaction executed on-chain β
β β’ Returns: { hash, fee } β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why Use This?
vs. Direct Wallet SDK
Feature | Direct Wallet SDK | With Spending Controls |
---|---|---|
Spending Limits | β None | β Per-agent limits |
Audit Trail | β No logging | β Full audit log |
Monitoring | β No visibility | β Real-time dashboard |
Multi-Agent | β Complex DIY | β Built-in management |
Compliance | β DIY | β Regulatory-ready |
Tamper Protection | β None | β Fingerprinting + single-use tokens |
Key Security | β You control | β You control |
vs. Custodial Solutions
Feature | Custodial Wallet Service | Agent Spending Controls |
---|---|---|
Key Custody | β Third-party holds keys | β You keep keys |
Liability | β High (custodian risk) | β Low (non-custodial) |
Trust Required | β Must trust custodian | β Minimal trust needed |
Policy Enforcement | β Yes | β Yes |
Vendor Lock-in | β High | β Wraps any wallet SDK |
Compliance | β οΈ Custodianβs responsibility | β Your control |
Use Cases
1. AI Shopping Agents
Agent can purchase items up to $100/day, preventing runaway spending on expensive items.
2. Automated Treasury Management
DeFi agent can rebalance positions with per-transaction limits and daily caps.
3. Customer Service Bots
Support agent can issue refunds up to $50 without human approval, larger amounts require oversight.
4. Research & Development
Grant access to multiple research agents, each with different budgets for experiments.
5. Multi-Agent Marketplaces
Platform with hundreds of agents, each with custom spending policies.
Roadmap
Phase 1: Proof of Concept β (Current)
- Basic spending limits (daily, per-transaction)
- Hourly spending limits
- Recipient whitelist controls
- Transaction frequency limits
- Two-gate enforcement model
- Real-time monitoring dashboard
- Audit logging
- Ethereum support (ETH + ERC-20)
- Multi-agent management
Phase 2: Production-Ready SDK (2-4 weeks)
- npm package distribution
- Persistent storage (PostgreSQL)
- Redis for token management
- Comprehensive test suite
- SDK for multiple wallet providers
- Docker deployment
- Production security hardening
Phase 3: Advanced Controls (1-2 months)
- Weekly/monthly limits
- Recipient blacklists
- Advanced velocity controls & rate limiting
- Multi-chain support (Bitcoin, Solana)
- Approval workflows
- Webhooks & notifications
Phase 4: Enterprise Features (3+ months)
- Fraud detection & anomaly detection
- Compliance reporting (KYC/AML)
- Multi-organisation support
- Role-based access control
- API rate limiting
- SaaS offering
Want to help? Check CONTRIBUTING.md and POLICY_CONTROLS.md!
Documentation
- ARCHITECTURE.md - Detailed technical documentation
- POLICY_CONTROLS.md - 100+ potential policy controls
- CONTRIBUTING.md - How to contribute
- Tether WDK Docs - Wallet SDK documentation
Security
Best Practises
β οΈ NEVER commit sensitive data:
- Seed phrases
- Private keys
- API keys
- Production credentials
All sensitive configuration belongs in .env
(gitignored).
Current Limitations (POC)
This is a proof of concept. Before production use:
- Replace in-memory storage with PostgreSQL
- Add Redis for distributed token management
- Implement rate limiting on API endpoints
- Add comprehensive input validation
- Security audit of JWT implementation
- Add monitoring & alerting
- Implement backup & recovery procedures
FAQ
Q: Do you custody my keys? A: No. Your keys remain on your infrastructure. We only enforce policy before you sign.
Q: Does this work with any wallet SDK? A: Currently demonstrated with Tether WDK. The SDK wrapper pattern works with any wallet library.
Q: What happens if your API goes down? A: Agents canβt make payments (fail-closed design). In production, deploy your own policy API with high availability.
Q: Can I use this in production? A: This is a POC. See βCurrent Limitationsβ above. Weβre working towards production-ready releases.
Q: Does the demo execute real blockchain transactions? A: No. The demo runs in dry-run mode and simulates blockchain execution. Policy enforcement (the core innovation) runs completely. To enable real transactions, uncomment the production code in src/sdk/policy-wallet.ts
and fund your wallet with ETH for gas.
Q: How do I add my own policy controls? A: Check CONTRIBUTING.md and POLICY_CONTROLS.md for guidance.
Q: Is there a hosted version? A: Not yet. Phase 1 is self-hosted. Hosted SaaS coming in Phase 4.
Contributing
We welcome contributions! This project is young and thereβs lots to build.
High-value contributions:
- Implement policy controls from POLICY_CONTROLS.md
- Add support for more wallet SDKs
- Write tests (unit, integration, security)
- Improve documentation & examples
- Add multi-chain support
See CONTRIBUTING.md for detailed guidelines.
License
MIT License - see LICENSE for details.
Acknowledgements
- Tether WDK - Multi-chain wallet SDK
- Agentic Commerce - Inspiration for agent-driven economy
Connect
- GitHub Issues: Report bugs or request features
- Twitter: @L1AD
- Email: