get_balance
Retrieve native token balance for a wallet on any blockchain, displaying amounts in both raw units and human-readable format to monitor asset holdings.
Instructions
Get the native token balance for a wallet on a specific chain. Returns balance in both wei (or lamports for Solana) and human-readable format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet_id | Yes | Wallet ID | |
| chain_id | No | Chain ID to check (defaults to wallet's default chain) |
Implementation Reference
- src/index.ts:406-421 (handler)The 'get_balance' tool implementation. This is the complete registration including the tool name, description, Zod schema for input validation (wallet_id and optional chain_id), and the async handler function that calls the API endpoint /wallets/${wallet_id}/balance to retrieve native token balances.
// ─── Tool: get_balance ─────────────────────────────────────────── server.tool( 'get_balance', 'Get the native token balance for a wallet on a specific chain. ' + 'Returns balance in both wei (or lamports for Solana) and human-readable format.', { wallet_id: z.number().int().describe('Wallet ID'), chain_id: z.number().int().optional().describe('Chain ID to check (defaults to wallet\'s default chain)'), }, async ({ wallet_id, chain_id }) => { const params = chain_id ? `?chain_id=${chain_id}` : ''; const data = await api(`/wallets/${wallet_id}/balance${params}`); return jsonResponse(data); }, );