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
| Name | Required | Description | Default |
|---|---|---|---|
| contractAddress | Yes | The deployed smart contract address | |
| input | No | JSON string with method and params | |
| sourceAddress | No | Optional 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"], }, },
- src/index.ts:1196-1214 (handler)MCP server handler for the tool: validates args and delegates to ZetrixSDK.callContractcase "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), }, ], }; }
- src/zetrix-sdk.ts:132-156 (handler)Core implementation of the contract call using official zetrix-sdk-nodejs: constructs params and calls sdk.contract.callasync 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)}` ); } }
- src/zetrix-sdk.ts:28-35 (schema)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; }