Skip to main content
Glama

evm_call_contract

Call read-only smart contract view/pure functions to query on-chain state without gas fees or transactions. Use it to fetch token balances, DEX reserves, NFT owners, and other contract data.

Instructions

Call a smart contract view/pure function for read-only access (no gas cost, no state changes).

Executes contract function locally without broadcasting transaction. Used to query contract state, read data, or simulate operations. No blockchain state modifications - perfect for getting information.

CRITICAL RULES:

  • Only works with view/pure functions (read-only)

  • NO gas cost (local execution)

  • Does NOT modify blockchain state

  • Requires contract ABI to understand function interface

  • Parameters must match function signature exactly

  • Returns data immediately (no transaction confirmation needed)

PARAMETERS:

  • chain: EVM chain where contract is deployed (required)

    • Contract must exist on specified chain

    • Different chains may have different contract instances

  • contractAddress: Smart contract address (required)

    • Format: 0x followed by 40 hex characters

    • Must be deployed contract

    • Examples: DEX routers, NFT contracts, lending pools

  • abi: Contract Application Binary Interface (required)

    • JSON array defining contract interface

    • Get from block explorer (verified contracts)

    • Defines function names, parameters, return types

    • Example: [{"name":"balanceOf","inputs":[...],"outputs":[...]}]

  • functionName: Name of function to call (required)

    • Must be view or pure function

    • Exact name as defined in contract

    • Case-sensitive (balanceOf ≠ BalanceOf)

    • Examples: "balanceOf", "totalSupply", "getReserves"

  • params: Function parameters array (optional)

    • Must match function signature order

    • Correct types: addresses as strings, numbers as strings

    • Empty array [] if function takes no parameters

    • Examples: ["0x742d35..."], ["100", "200"], []

EXAMPLES: ✅ Check token balance (ERC20 balanceOf): {chain: "polygon", contractAddress: "0x2791Bca...", abi: [...ERC20_ABI], functionName: "balanceOf", params: ["0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"]}

✅ Get DEX pool reserves: {chain: "arbitrum", contractAddress: "0xPairAddress...", abi: [...], functionName: "getReserves", params: []}

✅ Check NFT owner: {chain: "ethereum", contractAddress: "0xNFT...", abi: [...ERC721_ABI], functionName: "ownerOf", params: ["1"]}

❌ Invalid - trying to call write function: {functionName: "transfer"} // transfer modifies state, use evm_send_contract_transaction

❌ Invalid - wrong parameter count: {functionName: "balanceOf", params: []} // balanceOf requires address parameter

SUPPORTED EVM CHAINS (7 networks): • ethereum (Sepolia) - EIP-1559 enabled, ~12s blocks, moderate gas costs • polygon (Amoy) - Low fees, fast finality (~2s), layer 2 • avalanche (Fuji C-Chain) - Sub-second finality, dynamic fees • bsc (BNB Testnet) - 3s blocks, low gas costs, Binance ecosystem • arbitrum (Sepolia) - Optimistic rollup, low fees, Ethereum security • base (Sepolia) - Coinbase layer 2, EIP-1559, low fees • worldchain (World Sepolia) - World Network testnet, EIP-1559

CRITICAL GAS CONSIDERATIONS:

  • Ethereum: High gas costs, use gas oracle for timing

  • Polygon/BSC: Very low gas, safe for frequent transactions

  • Arbitrum/Base: L2 optimizations, ~10-50x cheaper than Ethereum

  • Avalanche: Dynamic fees, can spike during congestion

  • Always check gas price before executing transactions

TESTNET TOKENS: All chains use testnet tokens with NO REAL VALUE. Faucets available for all supported networks.

OUTPUT STRUCTURE: • success: Boolean indicating call success • chain: Chain queried • contractAddress: Contract called • functionName: Function executed • result: Return value(s) from function (decoded) • resultRaw: Raw hex-encoded return data • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Using with write functions (will fail - use evm_send_contract_transaction)

  • Wrong parameter types (address as number, etc.)

  • Missing required parameters

  • Wrong ABI (function signature doesn't match)

  • Incorrect parameter order

  • Not handling complex return types (tuples, arrays)

USE CASES:

  • Query token balances without transactions

  • Get DEX prices and reserves

  • Check NFT ownership and metadata URIs

  • Read lending protocol rates

  • Verify contract state before writing

  • Simulate operations locally

VIEW/PURE FUNCTIONS:

  • view: Reads blockchain state (storage, balance, etc.)

  • pure: No state access (pure computation)

  • Both execute locally (no gas, no transaction)

  • Common examples:

    • balanceOf(address) - token balance

    • totalSupply() - total tokens

    • getReserves() - DEX reserves

    • ownerOf(uint256) - NFT owner

GETTING CONTRACT ABI:

  1. Etherscan/PolygonScan - verified contracts show ABI

  2. Block explorer "Contract" tab

  3. Project GitHub repository

  4. npm packages for common contracts (@uniswap/v2-core)

ABI EXAMPLES: ERC20 balanceOf ABI: [{ "name": "balanceOf", "type": "function", "stateMutability": "view", "inputs": [{"name": "account", "type": "address"}], "outputs": [{"name": "balance", "type": "uint256"}] }]

RETURN VALUE TYPES:

  • Single value: Returned directly

  • Multiple values: Returned as array

  • Struct/tuple: Returned as object

  • Array: Returned as array

  • BigNumber strings for large numbers

Running on Linux.

LINUX-SPECIFIC NOTES:

  • Package manager: apt (Ubuntu/Debian), yum (RHEL/CentOS), or pacman (Arch)

  • Python 3 is typically 'python3' command

  • GNU tools are standard

  • Use 'xdg-open' command to open files/applications

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "chain": "<chain>",
      "contractAddress": "<contractAddress>",
      "abi": "<abi>",
      "functionName": "<functionName>"
    },
    "name": "evm_call_contract"
  }
}

Input Schema

NameRequiredDescriptionDefault
abiYesContract ABI (JSON array)
chainYesEVM chain to query
paramsNoFunction parameters (optional)
functionNameYesFunction name to call
contractAddressYesSmart contract address (0x...)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full burden and does so well: local execution, no gas cost, no state mutation, immediate return, and required ABI context are all stated. It loses a point because the 'CRITICAL GAS CONSIDERATIONS' and testnet faucet sections are irrelevant to a read-only call and could mislead an agent into thinking a transaction is broadcast.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Core content is front-loaded and well organized, but the definition is heavily bloated with off-topic material: seven-chain gas commentary, testnet faucet notes, ABI tutorials, and a stray Linux/package-manager section that has nothing to do with the tool. Much of this does not earn its place for an agent selecting and invoking the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by documenting the output structure (success, result, resultRaw, executionTime) and return-type handling for tuples/arrays. Combined with the ABI and parameter rules, an agent has what it needs; only the irrelevant sections dilute completeness rather than leave gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond the schema: ABI acquisition sources and JSON shape, exact-match function signature rules, case sensitivity of functionName, string-typed numeric params, ordering requirements, and empty-array convention for zero-arg functions. It goes past restating field names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource ("Call a smart contract view/pure function") and immediately scopes it to read-only access. It explicitly names the sibling it is not (evm_send_contract_transaction) for write functions, so an agent can differentiate without opening other schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use (query state, read data, simulate, verify state before writing), when-not-to-use (the '❌ Invalid - trying to call write function' example routes to evm_send_contract_transaction), and concrete usage examples with full argument sets. Alternatives and boundary conditions are named rather than left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools