zetrix_get_balance
Retrieve account balance 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
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | The Zetrix account address |
Implementation Reference
- src/zetrix-client.ts:302-317 (handler)Core implementation of getBalance: fetches account info via API, computes ZETRIX balance from ZETA micro-units using the conversion constant.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)}`); } }
- src/index.ts:846-859 (handler)MCP tool dispatch handler: extracts 'address' argument from tool call, invokes ZetrixClient.getBalance, returns JSON-formatted result.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), }, ], }; }
- src/index.ts:120-132 (schema)Tool schema definition: specifies name, description, and input schema requiring 'address' string for the MCP ListTools response.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"], }, },
- src/zetrix-client.ts:47-52 (schema)TypeScript interface defining the return type structure for balance queries.export interface ZetrixBalance { address: string; balance: string; // Balance in ZETA (micro units) balanceInZETRIX: string; // Balance in ZETRIX (main units) balanceInZTX: string; // Deprecated: use balanceInZETRIX }
- src/index.ts:60-766 (registration)Tool registration: the tools array populated with all tool definitions, used by ListToolsRequestSchema handler to advertise available tools.const tools: Tool[] = [ { name: "zetrix_check_health", description: "Check the health status of the Zetrix node", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_get_account", description: "Get Zetrix account information including balance and metadata", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, }, required: ["address"], }, }, { name: "zetrix_get_block", description: "Get information about a specific block by height", inputSchema: { type: "object", properties: { blockNumber: { type: "number", description: "The block height/number to query", }, }, required: ["blockNumber"], }, }, { name: "zetrix_get_latest_block", description: "Get the latest block information from Zetrix blockchain", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_get_transaction", description: "Get transaction details by transaction hash", inputSchema: { type: "object", properties: { hash: { type: "string", description: "The transaction hash", }, }, required: ["hash"], }, }, { 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"], }, }, { name: "zetrix_create_keypair", description: "Generate a new public-private key pair (for testing only)", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_get_account_base", description: "Get basic account information without assets and metadata", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, }, required: ["address"], }, }, { name: "zetrix_get_account_assets", description: "Get asset holdings for an account", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, code: { type: "string", description: "Asset code (optional, must be used with issuer)", }, issuer: { type: "string", description: "Asset issuer address (optional, must be used with code)", }, }, required: ["address"], }, }, { name: "zetrix_get_account_metadata", description: "Get metadata associated with an account", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, key: { type: "string", description: "Specific metadata key (optional)", }, }, required: ["address"], }, }, { name: "zetrix_get_transaction_history", description: "Get completed transaction records", inputSchema: { type: "object", properties: { hash: { type: "string", description: "Transaction hash (optional)", }, ledgerSeq: { type: "number", description: "Block sequence number (optional)", }, }, }, }, { name: "zetrix_get_transaction_cache", description: "Get pending transactions not yet executed", inputSchema: { type: "object", properties: { hash: { type: "string", description: "Transaction hash (optional)", }, limit: { type: "number", description: "Number of pending transactions to return (optional)", }, }, }, }, { name: "zetrix_get_ledger", description: "Get block/ledger information with optional details", inputSchema: { type: "object", properties: { seq: { type: "number", description: "Block sequence number (optional)", }, withValidator: { type: "boolean", description: "Include validator list (optional)", }, withConsValue: { type: "boolean", description: "Include consensus value (optional)", }, withFee: { type: "boolean", description: "Include fee configuration (optional)", }, }, }, }, { name: "zetrix_multi_query", description: "Execute multiple API queries simultaneously", inputSchema: { type: "object", properties: { items: { type: "array", description: "Array of query objects", }, }, required: ["items"], }, }, { name: "zetrix_get_transaction_blob", description: "Serialize transaction data into hexadecimal format", inputSchema: { type: "object", properties: { transaction: { type: "object", description: "Transaction object with source_address, nonce, fee_limit, gas_price, operations", }, }, required: ["transaction"], }, }, { name: "zetrix_submit_transaction", description: "Submit signed transaction to blockchain for execution", inputSchema: { type: "object", properties: { transactionBlob: { type: "string", description: "Serialized transaction blob", }, signatures: { type: "array", description: "Array of signature objects with sign_data and public_key", }, }, required: ["transactionBlob", "signatures"], }, }, { name: "zetrix_call_contract", description: "Call smart contract in sandbox environment for debugging", inputSchema: { type: "object", properties: { contractAddress: { type: "string", description: "Deployed contract address (optional)", }, code: { type: "string", description: "Contract source code (optional)", }, input: { type: "string", description: "Function parameters (optional)", }, contractBalance: { type: "string", description: "Contract balance (optional)", }, feeLimit: { type: "string", description: "Fee limit (optional)", }, gasPrice: { type: "string", description: "Gas price (optional)", }, optType: { type: "number", description: "Operation type (optional)", }, sourceAddress: { type: "string", description: "Source address (optional)", }, }, }, }, { name: "zetrix_test_transaction", description: "Evaluate transaction fees without blockchain submission", inputSchema: { type: "object", properties: { items: { type: "array", description: "Array of test transaction items", }, }, required: ["items"], }, }, { name: "zetrix_ws_connect", description: "Connect and register to Zetrix WebSocket for real-time updates", inputSchema: { type: "object", properties: { apiList: { type: "array", description: "Optional list of API message types to register (numbers)", }, }, }, }, { name: "zetrix_ws_submit_transaction", description: "Submit transaction via WebSocket and get real-time status updates", inputSchema: { type: "object", properties: { transaction: { type: "object", description: "Transaction object", }, signatures: { type: "array", description: "Array of signature objects with public_key and sign_data", }, trigger: { type: "object", description: "Optional trigger object", }, }, required: ["transaction", "signatures"], }, }, { name: "zetrix_ws_subscribe_tx", description: "Subscribe to transaction notifications for specific addresses", inputSchema: { type: "object", properties: { addresses: { type: "array", description: "Array of account addresses to subscribe to", }, }, required: ["addresses"], }, }, { name: "zetrix_ws_disconnect", description: "Disconnect from WebSocket", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_ws_status", description: "Check WebSocket connection status", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_sdk_create_account", description: "Create a new Zetrix account using the official SDK", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_sdk_get_balance", description: "Get account balance using the official SDK", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, }, required: ["address"], }, }, { name: "zetrix_sdk_is_activated", description: "Check if an account is activated on the blockchain", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, }, required: ["address"], }, }, { name: "zetrix_sdk_get_nonce", description: "Get account nonce (transaction sequence number)", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, }, required: ["address"], }, }, { name: "zetrix_sdk_call_contract", description: "Call a smart contract function (query only, no state change) using SDK", inputSchema: { type: "object", properties: { contractAddress: { type: "string", description: "The deployed smart contract address", }, input: { type: "string", description: "JSON string with method and params", }, sourceAddress: { type: "string", description: "Optional source address for the call", }, }, required: ["contractAddress"], }, }, { name: "zetrix_sdk_invoke_contract", description: "Invoke a smart contract function with state change (requires private key)", inputSchema: { type: "object", properties: { sourceAddress: { type: "string", description: "The account address initiating the transaction", }, privateKey: { type: "string", description: "Private key for signing the transaction", }, contractAddress: { type: "string", description: "The smart contract address to invoke", }, amount: { type: "string", description: "Amount of ZTX to send with invocation (in micro-ZTX)", }, input: { type: "string", description: "JSON string with method and params", }, metadata: { type: "string", description: "Optional transaction description", }, }, required: ["sourceAddress", "privateKey", "contractAddress", "amount", "input"], }, }, // Encryption Tools { name: "zetrix_crypto_generate_keypair", description: "Generate a new Zetrix key pair with private key, public key, and address", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_crypto_get_public_key", description: "Derive public key from private key", inputSchema: { type: "object", properties: { privateKey: { type: "string", description: "The encrypted private key", }, }, required: ["privateKey"], }, }, { name: "zetrix_crypto_get_address", description: "Get Zetrix address from public key", inputSchema: { type: "object", properties: { publicKey: { type: "string", description: "The public key", }, }, required: ["publicKey"], }, }, { name: "zetrix_crypto_validate_key", description: "Validate private key, public key, or address format", inputSchema: { type: "object", properties: { type: { type: "string", enum: ["privateKey", "publicKey", "address"], description: "Type of key to validate", }, value: { type: "string", description: "The key or address to validate", }, }, required: ["type", "value"], }, }, { name: "zetrix_crypto_sign", description: "Sign a message with a private key", inputSchema: { type: "object", properties: { message: { type: "string", description: "The message to sign (hex string)", }, privateKey: { type: "string", description: "The private key to sign with", }, }, required: ["message", "privateKey"], }, }, { name: "zetrix_crypto_verify", description: "Verify a signature against a message and public key", inputSchema: { type: "object", properties: { message: { type: "string", description: "The original message (hex string)", }, signature: { type: "string", description: "The signature to verify", }, publicKey: { type: "string", description: "The public key to verify against", }, }, required: ["message", "signature", "publicKey"], }, }, { name: "zetrix_crypto_encrypt_key", description: "Encrypt a private key with a password for secure storage", inputSchema: { type: "object", properties: { privateKey: { type: "string", description: "The private key to encrypt", }, password: { type: "string", description: "The password to use for encryption", }, }, required: ["privateKey", "password"], }, }, { name: "zetrix_crypto_decrypt_key", description: "Decrypt an encrypted private key with a password", inputSchema: { type: "object", properties: { encryptedData: { type: "string", description: "The encrypted keystore data", }, password: { type: "string", description: "The password used for encryption", }, }, required: ["encryptedData", "password"], }, }, // Smart Contract Development Tools { name: "zetrix_contract_get_chain_functions", description: "Get documentation for all built-in Chain object functions available in Zetrix smart contracts", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_contract_get_utils_functions", description: "Get documentation for all built-in Utils object functions available in Zetrix smart contracts", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_contract_get_structure_guide", description: "Get guide on how to structure Zetrix smart contracts with ES5 patterns, classes, and inheritance", inputSchema: { type: "object", properties: {}, }, }, { name: "zetrix_contract_get_token_standard", description: "Get token standard specification (ZTP20, ZTP721, or ZTP1155)", inputSchema: { type: "object", properties: { standard: { type: "string", enum: ["ZTP20", "ZTP721", "ZTP1155"], description: "Token standard to get documentation for", }, }, required: ["standard"], }, }, { name: "zetrix_contract_init_dev_environment", description: "Initialize a new Zetrix smart contract development environment using create-zetrix-tool. This creates a complete project structure with testing framework, examples, and utilities.", inputSchema: { type: "object", properties: { contractName: { type: "string", description: "Name of the contract project to create (alphanumeric and hyphens only)", }, workingDirectory: { type: "string", description: "Directory where to create the project (defaults to current directory)", }, }, required: ["contractName"], }, }, { name: "zetrix_contract_generate_advanced", description: "Generate advanced multi-class Zetrix smart contract with interfaces, libraries, utilities, main contract, and comprehensive test specs. **MANDATORY WORKFLOW: (1) First call zetrix_contract_init_dev_environment with contractName (e.g., 'CertificateContract'). (2) Then call this tool with the SAME contractName and outputDirectory set to './{contractName}'. Calling this tool WITHOUT initializing the project first will result in an error.** Supports complex architectures with inheritance, composition, and modular design.", inputSchema: { type: "object", properties: { contractName: { type: "string", description: "Name of the main contract (e.g., 'StableCoin', 'NFTMarketplace')", }, contractType: { type: "string", enum: ["token", "nft", "defi", "governance", "marketplace", "custom"], description: "Type of contract to generate", }, features: { type: "array", items: { type: "string", enum: ["pausable", "ownable", "roles", "upgradeable", "whitelist", "blacklist", "timelock", "oracle"], }, description: "Advanced features to include", }, tokenStandard: { type: "string", enum: ["ZTP20", "ZTP721", "ZTP1155"], description: "Token standard (required if contractType is 'token' or 'nft')", }, includeTests: { type: "boolean", description: "Generate comprehensive test specifications (default: true)", }, outputDirectory: { type: "string", description: "Directory to output the contract files (defaults to current directory)", }, }, required: ["contractName", "contractType"], }, }, { name: "zetrix_contract_get_testing_guide", description: "Get guide on testing Zetrix smart contracts with TEST_INVOKE and TEST_QUERY", inputSchema: { type: "object", properties: {}, }, }, ];