agentwallet-mastra
v5.0.1
Published
AgentWallet tools for Mastra — balance checks, USDC transfers, and x402 payments
Downloads
102
Maintainers
Readme
agentwallet-mastra
AgentWallet SDK tools for Mastra. Gives your Mastra agent on-chain wallet capabilities with budget enforcement and x402 payments.
Install
npm install agentwallet-mastra agentwallet-sdk @mastra/core zodUsage
import { Agent } from '@mastra/core/agent';
import { agentwalletTools } from 'agentwallet-mastra';
import { createWallet } from 'agentwallet-sdk';
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
const wallet = createWallet({
accountAddress: process.env.AGENT_ACCOUNT_ADDRESS,
chain: 'base',
walletClient: createWalletClient({
account: privateKeyToAccount(process.env.AGENT_PRIVATE_KEY),
chain: base,
transport: http(),
}),
});
const agent = new Agent({
name: 'PaymentAgent',
instructions: 'You can check your wallet balance, transfer USDC, and pay for x402 APIs.',
model: openai('gpt-4o'),
tools: Object.fromEntries(agentwalletTools.map(t => [t.id, t])),
context: { agentWallet: wallet },
});Tools
| Tool | Description |
|------|-------------|
| walletBalanceTool | Check remaining spend budget |
| walletTransferTool | Transfer USDC within budget limits |
| walletX402FetchTool | HTTP fetch with automatic x402 payment |
License
MIT
