Skip to main content
Glama

zetrix_sdk_call_contract

Query smart contract functions on the Zetrix blockchain without modifying state. Provide contract address and method parameters to retrieve data.

Instructions

Call a smart contract function (query only, no state change) using SDK

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe deployed smart contract address
inputNoJSON string with method and params
sourceAddressNoOptional source address for the call

Implementation Reference

  • src/index.ts:470-491 (registration)
    Tool registration definition including name, description, and input schema validation
    { 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"], }, },
  • MCP server handler for the tool: validates args and delegates to ZetrixSDK.callContract
    case "zetrix_sdk_call_contract": { if (!args) { throw new Error("Missing arguments"); } const result = await zetrixSDK.callContract({ contractAddress: args.contractAddress as string, optType: args.optType as number | undefined, input: args.input as string | undefined, sourceAddress: args.sourceAddress as string | undefined, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
  • Core implementation of the contract call using official zetrix-sdk-nodejs: constructs params and calls sdk.contract.call
    async callContract(params: ZetrixContractCallParams): Promise<any> { await this.initSDK(); try { const callParams: any = { contractAddress: params.contractAddress, optType: params.optType || 2, // 2 = query }; if (params.input) callParams.input = params.input; if (params.sourceAddress) callParams.sourceAddress = params.sourceAddress; const result = await this.sdk.contract.call(callParams); if (result.errorCode !== 0) { throw new Error(result.errorDesc || `SDK Error: ${result.errorCode}`); } return result.result; } catch (error) { throw new Error( `Failed to call contract: ${error instanceof Error ? error.message : String(error)}` ); } }
  • TypeScript interface defining parameters for the callContract method (matches tool inputSchema)
    export interface ZetrixContractCallParams { contractAddress: string; optType?: number; input?: string; sourceAddress?: string; amount?: string; metadata?: string; }

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