check_balance
Check available USDC and SOL balances for AI requests on SolanaProx using your wallet address.
Instructions
Check your current SolanaProx balance. Returns available USDC and SOL balance that can be used for AI requests.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | No | Solana wallet address to check. Defaults to configured wallet. |
Implementation Reference
- src/index.ts:274-296 (handler)The handler function that executes the check_balance tool logic. Extracts the wallet parameter from args, calls the getBalance helper function, and returns formatted balance information including USDC and SOL values.
case "check_balance": { const { wallet } = args as any; const balance = await getBalance(wallet); return { content: [ { type: "text", text: [ `💰 SolanaProx Balance`, `Wallet: ${balance.wallet || WALLET_ADDRESS}`, `Total: $${balance.total_usd?.toFixed(4)} USD`, `USDC: $${balance.usdc?.toFixed(4)}`, `SOL value: $${balance.sol_usd?.toFixed(4)}`, ``, balance.total_usd > 0 ? `✅ Ready to make AI requests` : `⚠️ No balance. Deposit USDC at ${SOLANAPROX_URL}`, ].join("\n"), }, ], }; } - src/index.ts:61-76 (schema)Tool registration and schema definition for check_balance. Defines the tool name, description, and inputSchema with an optional wallet parameter for specifying which Solana wallet address to check.
{ name: "check_balance", description: "Check your current SolanaProx balance. Returns available USDC and SOL balance that can be used for AI requests.", inputSchema: { type: "object", properties: { wallet: { type: "string", description: "Solana wallet address to check. Defaults to configured wallet.", }, }, required: [], }, }, - src/index.ts:174-190 (helper)Helper function getBalance() that makes the actual API call to fetch wallet balance from SolanaProx. Accepts an optional wallet parameter, constructs the API endpoint URL, and returns balance data including total_usd, usdc, sol_usd, and wallet address.
async function getBalance(wallet?: string): Promise<{ total_usd: number; usdc: number; sol_usd: number; wallet: string; }> { const targetWallet = wallet || WALLET_ADDRESS; const res = await fetch( `${SOLANAPROX_URL}/api/balance/${targetWallet}` ); if (!res.ok) { throw new Error(`Failed to fetch balance: ${res.statusText}`); } return res.json() as any; }