SDK Reference
Aibank Class
Main SDK entry point. Handles wallet management, agent creation, and catalog access.
Aibank
The top-level SDK class. Create an instance to manage wallets, agents, and access the service catalog.
Installation
bun add aibankConstructor
import { Aibank } from "aibank";
const aibank = new Aibank(config: AibankConfig);AibankConfig
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | -- | Your aibank API key (ak_ or gw_ prefix) |
privateKey | string | No | -- | Optional default signer private key |
rpcUrl | string | No | -- | Custom RPC URL. Overrides getblockApiKey. |
getblockApiKey | string | No | -- | GetBlock API key for auto RPC construction |
defaultChain | Chain | No | "base" | Default chain for operations |
walletBaseUrl | string | No | "http://localhost:4000" | Base URL of the aibank API |
Example
const aibank = new Aibank({
apiKey: "ak_your_api_key",
walletBaseUrl: "http://localhost:4000",
getblockApiKey: "your-getblock-key",
defaultChain: "base",
});Methods
createAgent(config)
Create a new agent with a freshly generated wallet. Returns the agent, its private key, and address.
Important: Save the returned privateKey -- aibank does not store it.
const { agent, privateKey, address } = aibank.createAgent({
name: "trading-bot",
dailyLimit: 50,
allowedChains: ["base", "ethereum"],
allowedAddresses: ["0xTrustedAddr"],
});
console.log(address); // "0x..."
console.log(privateKey); // "0x..." -- save this!AgentConfig
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | -- | Agent name |
dailyLimit | number | No | 100 | Max USDC spend per 24h |
allowedChains | Chain[] | No | all | Restrict to specific chains |
allowedAddresses | string[] | No | all | Restrict to specific recipients |
loadAgent(name, privateKey, limits?)
Load an existing agent from a stored private key.
const agent = aibank.loadAgent("trading-bot", "0xPrivateKey...", {
dailyLimit: 200,
});createWallet(opts)
Create a new managed wallet via the API.
const wallet = await aibank.createWallet({ name: "my-wallet" });
console.log(wallet.id); // UUIDReturns an AibankWallet instance.
listWallets()
List all wallets for this API key.
const wallets = await aibank.listWallets();
// Array of WalletInfo objectsgetWallet(walletId)
Get an AibankWallet client for an existing wallet. Does not make a network call.
const wallet = aibank.getWallet("wallet-uuid");
const balances = await wallet.getBalances();catalog
Access the service catalog. Returns an AibankCatalog instance (lazy, reused).
const services = await aibank.catalog.listServices({ category: "data" });Supported chains
The Chain type supports:
| Chain | Type |
|---|---|
ethereum | EVM |
base | EVM |
base-sepolia | EVM (testnet) |
ethereum-sepolia | EVM (testnet) |
solana | Solana |
arbitrum | EVM |
optimism | EVM |
polygon | EVM |
avalanche | EVM |
bsc | EVM |
Exports
The SDK exports the following:
export {
Aibank,
AibankGateway,
AibankAgent,
AibankWallet,
AibankCatalog,
createX402Fetch,
CHAIN_CONFIG,
EVM_CHAINS,
TOKEN_ADDRESSES,
isEvmChain,
getTokenAddress,
getBlockRpcUrl,
} from "aibank";