@starrohan/agentpay
v1.3.0
Published
Autonomous agent wallets with built-in spending policies for Ethereum
Maintainers
Readme
@starrohan/agentpay
The wallet protocol for AI agents. Give any AI agent a crypto wallet, spending limits, and transaction history in 3 lines of code.
The problem
AI agents can think. They can't pay.
Millions of agents are being deployed to do real work — browse the web, call APIs, hire services. But every one hits the same wall: no way to handle money autonomously.
AgentPay fixes that.
Install
npm install @starrohan/agentpayQuickstart — 1 command
Initialize your agent project in 5 seconds:
npx agentpayUsage — 3 lines
import "dotenv/config";
import { AgentWallet, policy } from "@starrohan/agentpay";
const agent = new AgentWallet({
privateKey: process.env.AGENT_PRIVATE_KEY as `0x${string}`,
agentId: "my-agent",
policy: policy().maxTx(0.001).dailyLimit(0.01).build()
});
await agent.pay({ to: "0xRECIPIENT", amount: 0.00001, memo: "API call" });That's it. Your agent now has a wallet, spending limits, and a full transaction history.
Features
- 💳 Autonomous payments — agent sends crypto with no human clicking anything
- 🛡️ Spending policy — set max per transaction, daily limits, and recipient allowlists — enforced in code
- 📋 Transaction history — every payment logged with timestamp, memo, and status
- 📊 Daily spend tracker — know exactly how much your agent spent today
- ⚡ Base L2 — sub-second settlement, near-zero gas fees (~$0.000001 per tx)
- 🔌 Framework agnostic — works with LangChain, AutoGen, CrewAI, or any agent
Examples & Use Cases
Check out our examples/ directory for high-impact integrations:
- 🤖 Self-Sustaining Agent — An agent that pays for its own OpenAI/Anthropic API usage.
- 🦜 LangChain Official Plugin — Built-in Tool support for LangChain agents.
- 🤝 CrewAI Support — Native tool generator for multi-agent workflows.
- 🤖 AutoGen Integration — JSON Schema & implementation for AutoGen functions.
- 🤖 Claude Desktop / MCP Support — Use AgentPay directly in Claude with zero code.
- 🤖 Self-Sustaining Agent — An agent that pays for its own OpenAI/Anthropic API usage.
- 🕵️ Autonomous Researcher — Paying for premium data and search APIs.
🌟 Agent Showcase
Are you building something with AgentPay? Submit a PR to add your project here!
- [Your Project Name] — A brief description of what your agent does.
Badges
Show the world your agent is self-funded:
[](https://github.com/starrohan-dotcom/agentpay)
Integrations
LangChain
AgentPay provides an official LangChain tool for easy integration.
import { AgentWallet, AgentPayTool } from "@starrohan/agentpay";
const agent = new AgentWallet({ privateKey: "0x..." });
await agent.init();
const agentPayTool = new AgentPayTool(agent);CrewAI
Generate tools compatible with CrewAI agents:
import { AgentWallet, createCrewAIPayTool } from "@starrohan/agentpay";
const wallet = new AgentWallet({ privateKey: "0x..." });
await wallet.init();
const walletTool = createCrewAIPayTool(wallet);
// const agent = new Agent({ tools: [walletTool], ... });AutoGen
Native function registration for AutoGen:
import { AgentWallet, getAutoGenPayTool } from "@starrohan/agentpay";
const wallet = new AgentWallet({ privateKey: "0x..." });
await wallet.init();
const { schema, implementation } = getAutoGenPayTool(wallet);
// register_function(implementation, schema, ...);Claude Desktop / MCP
AgentPay supports the Model Context Protocol (MCP). You can give your Claude Desktop AI a wallet in 60 seconds.
Open your Claude Desktop config:
- macOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
Add AgentPay to the
mcpServerslist:
{
"mcpServers": {
"agentpay": {
"command": "npx",
"args": ["-y", "@starrohan/agentpay", "mcp"],
"env": {
"AGENT_PRIVATE_KEY": "0xYOUR_PRIVATE_KEY_HERE",
"RPC_URL": "https://sepolia.base.org"
}
}
}
}- Restart Claude. You will now see a 💳 icon, and you can ask Claude: "What is my wallet balance?" or "Send 0.001 ETH to 0x..."
Claude Code (CLI)
If you use Anthropic's terminal agent, run:
claude mcp add agentpay npx -y @starrohan/agentpay mcpRoo Code (VS Code)
AgentPay works perfectly with Roo Code.
- Open the Roo Code side panel in VS Code.
- Click on the MCP Settings icon (or open
.roo/mcp_settings.json). - Add the following configuration:
{
"mcpServers": {
"agentpay": {
"command": "npx",
"args": ["-y", "@starrohan/agentpay", "mcp"],
"env": {
"AGENT_PRIVATE_KEY": "0xYOUR_PRIVATE_KEY_HERE",
"RPC_URL": "https://sepolia.base.org"
}
}
}
}- Roo Code will automatically detect the new tools. You can now tell Roo: "Pay for the API credits using my AgentPay wallet."
API Reference
new AgentWallet(config)
const agent = new AgentWallet({
privateKey: "0x...", // agent's wallet private key
agentId: "my-agent", // optional human-readable name
policy: SpendingPolicy, // optional spending rules
rpcUrl: "https://...", // optional custom RPC (default: Base Sepolia)
});policy() — spending policy builder
const rules = policy()
.maxTx(0.001) // max 0.001 ETH per transaction
.dailyLimit(0.01) // max 0.01 ETH per day
.allowOnly(["0xABC...", "0xDEF..."]) // whitelist of allowed recipients
.warnAbove(0.0005) // log warning for large payments
.build();agent.pay(opts) → TxRecord
const tx = await agent.pay({
to: "0xRECIPIENT_ADDRESS",
amount: 0.00001, // in ETH
memo: "weather API call", // optional label
});
console.log(tx.hash); // transaction hash
console.log(tx.status); // "success" | "failed"
console.log(tx.timestamp); // DatePolicy violations throw immediately — the payment never goes out:
Error: [AgentPay] Policy violation: tx amount 99 ETH exceeds maxTxAmount 0.001 ETHSecurity
- ✅ Persistent state — daily limits and transaction history survive agent restarts (supports File, Redis, or SQL)
- ✅ Smart Accounts (ERC-7579) — optional on-chain wallet for "un-hackable" security
- ✅ USDC Support — native stablecoin payments on Base
- ✅ BigInt math — all internal calculations use Wei for absolute precision (no floating-point errors)
- ✅ Environment variables — secure private key management via
.envsupport - ✅ Policy enforcement — autonomous guardrails that cannot be bypassed by agent logic
agent.balance() → string
const bal = await agent.balance();
console.log(bal); // "0.000079 ETH"agent.history() → TxRecord[]
const txs = agent.history();
// [{ hash, to, amount, memo, timestamp, status }, ...]agent.dailySpentSoFar(token?) → string
const spent = agent.dailySpentSoFar("USDC");
console.log(`Agent spent ${spent} USDC today`);agent.summary()
Prints a full summary of all assets to console:
[AgentPay] ── my-agent Summary ──
Address: 0x5908AE35...
Balance: 0.000079 ETH | 150.00 USDC
Spent today: 0.00001 ETH | 5.00 USDC
Transactions: 1
Daily limit: 0.01 (Policy enforced)Real example output
Agent balance: 0.000089873993838909 ETH
[AgentPay] my-agent paying 0.00001 ETH to 0x71C7... (paying for weather API call)...
[AgentPay] ✅ Payment sent!
[AgentPay] 🔗 https://sepolia.basescan.org/tx/0x8be8d2...
Policy blocked the payment: tx amount 99 ETH exceeds maxTxAmount 0.00001 ETH
[AgentPay] ── my-agent Summary ──
Address: 0x5908AE35...
Balance: 0.000079 ETH | 150.00 USDC
Spent today: 0.00001 ETH | 5.00 USDC
Transactions: 1
Daily limit: 0.01 (Policy enforced)Network
Supports Base Sepolia testnet and Base Mainnet.
To use Mainnet, simply provide a Mainnet RPC URL in the config:
const agent = new AgentWallet({
privateKey: "0x...",
rpcUrl: "https://mainnet.base.org" // Default is Base Sepolia
});Roadmap
- [x] AgentWallet class with pay, balance, history
- [x] Spending policy engine (maxTx, dailyLimit, allowlist)
- [x] Base Sepolia testnet
- [x] Persistent state & BigInt precision (v1.1.1)
- [x] USDC support (v1.2.0)
- [x] Smart Account (ERC-7579) integration (v1.2.0)
- [x] LangChain / AutoGen / CrewAI plugins (v1.2.0)
- [x] Claude Desktop / MCP Support (v1.2.0)
- [ ] Enterprise dashboard
- [ ] Agent-to-agent payments
Built by
@starrohan-dotcom — building the economic infrastructure for AI agents.
Follow the journey on X: @starrohan
License
MIT
