Skip to main content
Glama

wallet_call

Interact with smart contracts on Ethereum and EVM-compatible blockchains by calling contract methods without executing transactions. Use wallet details, transaction data, and optional block tags for precise queries.

Instructions

Call a contract method without sending a transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockTagNoOptional block tag (latest, pending, etc.)
transactionYesThe transaction to call
walletNoThe wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set.

Implementation Reference

  • The main handler function for 'wallet_call' that performs a static contract call using ethers.Wallet.call()
    export const callHandler = async (input: any): Promise<ToolResultSchema> => {
      try {
        if (!input.transaction) {
          return createErrorResponse("Transaction is required");
        }
    
        const wallet = await getWallet(input.wallet, input.password);
    
        if (!wallet.provider) {
          return createErrorResponse("Provider is required to call a contract, please set the provider URL");
        }
    
        const result = await wallet.call(input.transaction, input.blockTag);
    
        return createSuccessResponse(
        `Contract call executed successfully
          Result: ${result}
        `);
      } catch (error) {
        return createErrorResponse(`Failed to call contract: ${(error as Error).message}`);
      }
    };
  • Input schema definition for the wallet_call tool, including parameters for wallet, transaction object, and blockTag
    {
      name: "wallet_call",
      description: "Call a contract method without sending a transaction",
      inputSchema: {
        type: "object",
        properties: {
          wallet: { type: "string", description: "The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set." },
          transaction: { 
            type: "object", 
            description: "The transaction to call",
            properties: {
              to: { type: "string" },
              from: { type: "string" },
              data: { type: "string" },
              value: { type: "string" },
              gasLimit: { type: "string" },
              gasPrice: { type: "string" }
            },
            required: ["to"]
          },
          blockTag: { type: "string", description: "Optional block tag (latest, pending, etc.)" }
        },
        required: ["transaction"]
      }
    },
  • src/tools.ts:556-608 (registration)
    The handlers dictionary where 'wallet_call' is registered to map to the callHandler function
    export const handlers: HandlerDictionary = {
      // Provider Methods
      "wallet_provider_set": setProviderHandler,
      // Wallet Creation and Management
      "wallet_create_random": createWalletHandler,
      "wallet_from_private_key": fromPrivateKeyHandler,
      "wallet_from_mnemonic": fromMnemonicHandler,
      "wallet_from_encrypted_json": fromEncryptedJsonHandler,
      "wallet_encrypt": encryptWalletHandler,
    
      // Wallet Properties
      "wallet_get_address": getAddressHandler,
      "wallet_get_public_key": getPublicKeyHandler,
      "wallet_get_private_key": getPrivateKeyHandler,
    
      // Blockchain Methods
      "wallet_get_balance": getBalanceHandler,
      "wallet_get_chain_id": getChainIdHandler,
      "wallet_get_gas_price": getGasPriceHandler,
      "wallet_get_transaction_count": getTransactionCountHandler,
      "wallet_call": callHandler,
    
      // Transaction Methods
      "wallet_send_transaction": sendTransactionHandler,
      "wallet_sign_transaction": signTransactionHandler,
      "wallet_populate_transaction": populateTransactionHandler,
    
      // Signing Methods
      "wallet_sign_message": signMessageHandler,
      "wallet_sign_typed_data": signTypedDataHandler,
      "wallet_verify_message": verifyMessageHandler,
      "wallet_verify_typed_data": verifyTypedDataHandler,
    
      // Provider Methods
      "provider_get_block": getBlockHandler,
      "provider_get_transaction": getTransactionHandler,
      "provider_get_transaction_receipt": getTransactionReceiptHandler,
      "provider_get_code": getCodeHandler,
      "provider_get_storage_at": getStorageAtHandler,
      "provider_estimate_gas": estimateGasHandler,
      "provider_get_logs": getLogsHandler,
      "provider_get_ens_resolver": getEnsResolverHandler,
      "provider_lookup_address": lookupAddressHandler,
      "provider_resolve_name": resolveNameHandler,
    
      // Network Methods
      "network_get_network": getNetworkHandler,
      "network_get_block_number": getBlockNumberHandler,
      "network_get_fee_data": getFeeDataHandler,
    
      // Mnemonic Methods
      "wallet_create_mnemonic_phrase": createMnemonicPhraseHandler
    };

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/dcSpark/mcp-cryptowallet-evm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server