Wallets & Transfers
Create wallets, check balances, send tokens, swap, bridge, and manage spending controls.
Wallets & Transfers
Every agent in aibank operates through a managed wallet that supports multiple blockchains. This guide covers the full lifecycle: creating wallets, checking balances, transferring tokens, and configuring spending controls.
Prerequisites
- An API key (from self-registration or platform creation)
- The aibank SDK:
bun add aibank
1. Create a wallet
import { Aibank } from "aibank";
const aibank = new Aibank({
apiKey: "ak_your_key",
walletBaseUrl: "http://localhost:4000",
});
const wallet = await aibank.createWallet({ name: "my-agent" });
console.log(wallet.id); // UUIDEach wallet gets addresses on all supported chains:
| Chain | Address type |
|---|---|
| Ethereum | EVM (0x...) |
| Base | EVM (same as Ethereum) |
| Solana | Ed25519 |
2. Check balances
const balances = await wallet.getBalances();
// {
// wallet_id: "uuid",
// balances: [
// { chain: "ethereum", token: "ETH", balance: "0.05" },
// { chain: "base", token: "USDC", balance: "100.00" },
// { chain: "solana", token: "SOL", balance: "1.5" }
// ]
// }Balances are fetched live from all supported chains.
3. Transfer tokens
const result = await wallet.transfer({
chain: "base",
to: "0xRecipientAddress...",
amount: "10.00",
currency: "USDC",
});
console.log(result.tx_hash); // "0xabc..."
console.log(result.status); // "confirmed"Supported chains and currencies
| Chain | Native | Stablecoins |
|---|---|---|
ethereum | ETH | USDC |
base | ETH | USDC |
solana | SOL | USDC |
4. Swap tokens
Swap one token for another on the same chain:
const result = await wallet.swap({
chain: "base",
inputToken: "ETH",
outputToken: "USDC",
amount: "0.1",
});The API accepts both camelCase (inputToken) and snake_case (input_token) parameter names.
5. Bridge tokens
Move tokens between chains:
curl -X POST http://localhost:4000/v1/wallets/WALLET_ID/bridge \
-H "X-API-Key: ak_your_key" \
-H "Content-Type: application/json" \
-d '{
"sourceChain": "ethereum",
"destinationChain": "base",
"token": "USDC",
"amount": "50.00"
}'6. Fund a wallet
Request a deposit address for incoming funds:
const funding = await wallet.requestFunding({
amount: "100.00",
chain: "base",
currency: "USDC",
});
console.log(funding.deposit_address); // "0x..."
console.log(funding.message); // "Send 100.00 USDC to 0x... on base"7. Withdraw to external address
const result = await wallet.withdraw({
chain: "base",
to: "0xExternalAddress...",
amount: "50.00",
currency: "USDC",
});8. Transaction history
const history = await wallet.getTransactions({
limit: 20,
chain: "base",
});
// history.transactions — array of WalletTransaction
// history.pagination — { total, limit, offset, has_more }Filter options:
| Parameter | Type | Description |
|---|---|---|
limit | number | Max records (default 50, max 200) |
offset | number | Pagination offset |
status | string | Filter: pending, confirmed, failed |
chain | string | Filter by chain |
9. Spending controls
Set guardrails on how much a wallet can spend:
// Set controls
await wallet.setControls({
daily_limit_usd: 100,
per_tx_limit_usd: 25,
allowed_addresses: ["0xTrustedAddress1", "0xTrustedAddress2"],
});
// Get controls with usage stats
const controls = await wallet.getControls();
// controls.usage_today.spent_usd — how much spent today
// controls.usage_today.remaining_usd — remaining daily budgetControl parameters
| Parameter | Type | Description |
|---|---|---|
daily_limit_usd | number | Max USD spend per day (0 = unlimited) |
weekly_limit_usd | number | Max USD spend per week |
monthly_limit_usd | number | Max USD spend per month |
per_tx_limit_usd | number | Max USD per single transaction |
allowed_addresses | string[] | Allowlist of recipient addresses |
allowed_domains | string[] | Allowlist of domains |
10. Delete a wallet
curl -X DELETE http://localhost:4000/v1/wallets/WALLET_ID \
-H "X-API-Key: ak_your_key"This permanently removes the wallet, all transactions, and spending controls.