get_sui_balance
Retrieve SUI token balance for any Sui blockchain address on mainnet or testnet networks using Grove's blockchain data service.
Instructions
Get SUI balance for an address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Sui address | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- src/handlers/sui-handlers.ts:303-318 (handler)Handler logic in handleSuiTool function that processes arguments, calls SuiService.getBalance, and returns the result as MCP tool response.case 'get_sui_balance': { const address = args?.address as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await suiService.getBalance(address, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- src/handlers/sui-handlers.ts:18-32 (schema)Input schema for the get_sui_balance tool, requiring 'address' and optionally 'network'.inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Sui address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['address'], },
- src/handlers/sui-handlers.ts:15-33 (registration)Tool registration object defining name, description, and schema for get_sui_balance, returned by registerSuiHandlers.{ name: 'get_sui_balance', description: 'Get SUI balance for an address', inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Sui address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['address'], }, },
- src/services/sui-service.ts:17-54 (helper)Core implementation of getBalance in SuiService: calls suix_getBalance RPC method and formats the response with human-readable SUI balance.async getBalance( address: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { const service = this.blockchainService.getServiceByBlockchain('sui', network); if (!service) { return { success: false, error: `Sui service not found for ${network}`, }; } const result = await this.blockchainService.callRPCMethod( service.id, 'suix_getBalance', [address] ); if (result.success && result.data) { // Add human-readable balance (SUI has 9 decimals) const totalBalance = BigInt(result.data.totalBalance || '0'); const sui = Number(totalBalance) / 1e9; return { success: true, data: { address, totalBalance: result.data.totalBalance, sui, coinType: result.data.coinType || '0x2::sui::SUI', }, metadata: result.metadata, }; } return result; }