zetrix_call_contract
Execute smart contract functions in a sandbox environment to test and debug blockchain interactions before deployment.
Instructions
Call smart contract in sandbox environment for debugging
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contractAddress | No | Deployed contract address (optional) | |
| code | No | Contract source code (optional) | |
| input | No | Function parameters (optional) | |
| contractBalance | No | Contract balance (optional) | |
| feeLimit | No | Fee limit (optional) | |
| gasPrice | No | Gas price (optional) | |
| optType | No | Operation type (optional) | |
| sourceAddress | No | Source address (optional) |
Implementation Reference
- src/index.ts:300-340 (registration)Registration of the 'zetrix_call_contract' tool including name, description, and input schema definition.{ 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)", }, }, }, },
- src/index.ts:1020-1040 (handler)Dispatch handler in main switch statement that maps input arguments to RPC parameters and calls ZetrixClient.callContractcase "zetrix_call_contract": { const params: any = {}; if (args?.contractAddress) params.contract_address = args.contractAddress; if (args?.code) params.code = args.code; if (args?.input) params.input = args.input; if (args?.contractBalance) params.contract_balance = args.contractBalance; if (args?.feeLimit) params.fee_limit = args.feeLimit; if (args?.gasPrice) params.gas_price = args.gasPrice; if (args?.optType) params.opt_type = args.optType; if (args?.sourceAddress) params.source_address = args.sourceAddress; const result = await zetrixClient.callContract(params); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/zetrix-client.ts:562-588 (handler)Core implementation of contract call: sends POST request to /callContract RPC endpoint with parameters and handles response/error.async callContract(params: { contract_address?: string; code?: string; input?: string; contract_balance?: string; fee_limit?: string; gas_price?: string; opt_type?: number; source_address?: string; }): Promise<ZetrixContractCallResult> { try { const response = await this.client.post("/callContract", params); if (response.data.error_code !== 0) { throw new Error( response.data.error_desc || `API Error: ${response.data.error_code}` ); } return response.data.result; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to call contract: ${error.message}`); } throw error; } }