Skip to main content
Glama

zetrix_get_balance

Retrieve account balances on the Zetrix blockchain, displaying amounts in both ZETRIX main units and ZETA micro units for accurate financial tracking.

Instructions

Get the ZETRIX balance of an account. Returns balance in both ZETA (micro units) and ZETRIX (main units). Note: 1 ZETRIX = 1,000,000 ZETA

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe Zetrix account address

Implementation Reference

  • Core handler function that executes the tool logic: fetches account info via API, computes balance in both ZETA (micro) and ZETRIX (main) units.
    async getBalance(address: string): Promise<ZetrixBalance> { try { const account = await this.getAccount(address); const balanceInZETA = BigInt(account.balance); const balanceInZETRIX = Number(balanceInZETA) / ZETRIX_CONSTANTS.ZETA_PER_ZETRIX; return { address, balance: account.balance, // Balance in ZETA (micro units) balanceInZETRIX: balanceInZETRIX.toFixed(6), // Balance in ZETRIX (main units) balanceInZTX: balanceInZETRIX.toFixed(6), // Deprecated: kept for backwards compatibility }; } catch (error) { throw new Error(`Failed to get balance: ${error instanceof Error ? error.message : String(error)}`); } }
  • MCP server handler that receives tool call, validates args, invokes ZetrixClient.getBalance, and formats response.
    case "zetrix_get_balance": { if (!args) { throw new Error("Missing arguments"); } const result = await zetrixClient.getBalance(args.address as string); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
  • Tool schema definition including name, description, and input validation schema requiring 'address' string.
    name: "zetrix_get_balance", description: "Get the ZETRIX balance of an account. Returns balance in both ZETA (micro units) and ZETRIX (main units). Note: 1 ZETRIX = 1,000,000 ZETA", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, }, required: ["address"], }, },
  • Helper method called by getBalance to fetch raw account data from Zetrix RPC API (/getAccount endpoint).
    async getAccount(address: string): Promise<ZetrixAccount> { try { const response = await this.client.get("/getAccount", { params: { address }, }); if (response.data.error_code !== 0) { throw new Error( response.data.error_desc || `API Error: ${response.data.error_code}` ); } const account = response.data.result; return { address: account.address || address, balance: account.balance || "0", nonce: account.nonce || 0, metadata: account.metadatas, }; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to get account: ${error.message}`); } throw error; } }
  • Type definition for the balance response structure returned by the tool.
    export interface ZetrixBalance { address: string; balance: string; // Balance in ZETA (micro units) balanceInZETRIX: string; // Balance in ZETRIX (main units) balanceInZTX: string; // Deprecated: use balanceInZETRIX }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Zetrix-Chain/zetrix-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server