aibank
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 aibank

Constructor

import { Aibank } from "aibank";

const aibank = new Aibank(config: AibankConfig);

AibankConfig

PropertyTypeRequiredDefaultDescription
apiKeystringYes--Your aibank API key (ak_ or gw_ prefix)
privateKeystringNo--Optional default signer private key
rpcUrlstringNo--Custom RPC URL. Overrides getblockApiKey.
getblockApiKeystringNo--GetBlock API key for auto RPC construction
defaultChainChainNo"base"Default chain for operations
walletBaseUrlstringNo"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

PropertyTypeRequiredDefaultDescription
namestringYes--Agent name
dailyLimitnumberNo100Max USDC spend per 24h
allowedChainsChain[]NoallRestrict to specific chains
allowedAddressesstring[]NoallRestrict 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); // UUID

Returns an AibankWallet instance.

listWallets()

List all wallets for this API key.

const wallets = await aibank.listWallets();
// Array of WalletInfo objects

getWallet(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:

ChainType
ethereumEVM
baseEVM
base-sepoliaEVM (testnet)
ethereum-sepoliaEVM (testnet)
solanaSolana
arbitrumEVM
optimismEVM
polygonEVM
avalancheEVM
bscEVM

Exports

The SDK exports the following:

export {
  Aibank,
  AibankGateway,
  AibankAgent,
  AibankWallet,
  AibankCatalog,
  createX402Fetch,
  CHAIN_CONFIG,
  EVM_CHAINS,
  TOKEN_ADDRESSES,
  isEvmChain,
  getTokenAddress,
  getBlockRpcUrl,
} from "aibank";

On this page