spraay-agent-wallet
v1.0.0
Published
Smart contract wallet provisioning for AI agents on Base. Session keys, spending limits, and time-bound permissions. Forked from Abstract Global Wallet.
Maintainers
Readme
spraay-agent-wallet 💧
Smart contract wallet provisioning for AI agents on Base. Forked from Abstract Global Wallet.
Factory-deployed minimal proxies with session keys, spending limits, and time-bound permissions — accessed via the Spraay x402 Gateway.
Install
npm install spraay-agent-walletQuick Start
import { SpraayWallet } from 'spraay-agent-wallet';
const sw = new SpraayWallet({
privateKey: process.env.EVM_PRIVATE_KEY, // Wallet with USDC on Base
});
// 1. Provision a wallet for your agent ($0.05 USDC)
const result = await sw.provision({
agentId: 'trading-bot-007',
agentType: 'langchain',
mode: 'managed',
});
console.log('Wallet:', result.wallet.walletAddress);
// 2. Add a session key with spending limits ($0.02 USDC)
const session = await sw.addSessionKey({
walletAddress: result.wallet.walletAddress,
sessionKeyAddress: '0xYourSignerAddress',
spendLimitEth: '0.5',
durationHours: 24,
allowedTargets: ['0xBatchContract'],
});
console.log('Expires:', session.session.expiresAt);
// 3. Query wallet info ($0.005 USDC)
const info = await sw.info(result.wallet.walletAddress);
console.log('Balance:', info.wallet.balanceEth, 'ETH');
// 4. Revoke a session key ($0.02 USDC)
await sw.revokeSessionKey(result.wallet.walletAddress, '0xOldSessionKey');
// 5. Predict address before deploying ($0.001 USDC)
const predicted = await sw.predictAddress('0xOwner', 'my-agent');
console.log('Will deploy to:', predicted.predictedAddress);API
new SpraayWallet(config)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| privateKey | string | — | EVM private key (wallet with USDC on Base) |
| x402PaymentHeader | string | — | Pre-built x402 payment header |
| gatewayUrl | string | https://gateway.spraay.app | Gateway URL |
| chainId | number | 8453 | Chain ID |
Methods
| Method | Price | Description |
|--------|-------|-------------|
| provision(options) | $0.05 | Deploy a smart contract wallet for an agent |
| addSessionKey(options) | $0.02 | Add a session key with spend limits + expiry |
| info(address) | $0.005 | Get wallet balance, metadata, session keys |
| revokeSessionKey(wallet, key) | $0.02 | Revoke a session key immediately |
| predictAddress(owner, agentId) | $0.001 | Predict wallet address before deployment |
Convenience
import { createSpraayWallet } from 'spraay-agent-wallet';
const sw = createSpraayWallet(process.env.EVM_PRIVATE_KEY);Contracts
Deployed on Base mainnet:
| Contract | Address |
|----------|---------|
| Factory | 0xFBD832Db6D9a05A0434cd497707a1bDC43389CfD |
| Implementation | 0x61818Ae8bC161D1884Fd8823985B80e6733C34E7 |
Also on Base Sepolia testnet:
| Contract | Address |
|----------|---------|
| Factory | 0xe483F189af41FB5479cd8695DbbA16cc5CF1071D |
| Implementation | 0xb6843955D914aD61dc6A4C819E0734d96467a391 |
How It Works
- Agent pays $0.05 USDC via x402 to the Spraay Gateway
- Gateway calls the factory contract on Base
- Factory deploys a minimal proxy (EIP-1167) via CREATE2
- Agent receives a smart contract wallet with:
- Session keys — temporary signers with spending caps
- Time bounds — automatic expiry
- Target restrictions — whitelist specific contracts
- Agent metadata — identity for trust scoring
Exports
The package also exports contract ABIs and addresses for direct interaction:
import { FACTORY_ABI, WALLET_ABI, ADDRESSES } from 'spraay-agent-wallet';Links
License
GPL-3.0 — same as the Abstract Global Wallet contracts this was forked from.
