call_contract_view
Query read-only smart contract functions to retrieve blockchain data without executing transactions, supporting multiple networks through Grove's Pocket Network integration.
Instructions
Call a read-only contract function
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockchain | Yes | Blockchain name | |
| contractAddress | Yes | Contract address | |
| data | Yes | Encoded function call data | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- Core handler implementation that executes the read-only contract function call via eth_call RPC on the blockchain service.async callContractView( blockchain: string, contractAddress: string, data: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { const service = this.blockchainService.getServiceByBlockchain(blockchain, network); if (!service) { return { success: false, error: `Blockchain service not found: ${blockchain} (${network})`, }; } return this.blockchainService.callRPCMethod( service.id, 'eth_call', [ { to: contractAddress, data: data, }, 'latest', ] ); }
- src/handlers/contract-handlers.ts:59-81 (handler)MCP dispatch handler for 'call_contract_view' tool: extracts arguments from input and calls the blockchain service method.case 'call_contract_view': { const blockchain = args?.blockchain as string; const contractAddress = args?.contractAddress as string; const data = args?.data as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await advancedBlockchain.callContractView( blockchain, contractAddress, data, network ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- src/handlers/contract-handlers.ts:15-41 (registration)MCP tool registration definition including name, description, and input schema validation.{ name: 'call_contract_view', description: 'Call a read-only contract function', inputSchema: { type: 'object', properties: { blockchain: { type: 'string', description: 'Blockchain name', }, contractAddress: { type: 'string', description: 'Contract address', }, data: { type: 'string', description: 'Encoded function call data', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['blockchain', 'contractAddress', 'data'], }, },