Skip to main content
Glama

provider_get_code

Retrieve the smart contract code stored at a specific Ethereum or EVM-compatible blockchain address. Specify the address and optional block tag for accurate code retrieval.

Instructions

Get the code at an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe address to get code from
blockTagNoOptional block tag (latest, pending, etc.)

Implementation Reference

  • The main handler function for 'provider_get_code' that retrieves the contract bytecode at the specified address using the configured provider.
    export const getCodeHandler = async (input: any): Promise<ToolResultSchema> => {
      try {
        if (!input.address) {
          return createErrorResponse("Address is required");
        }
    
        const provider = getProvider();
        const code = await provider.getCode(input.address, input.blockTag);
    
        return createSuccessResponse(
        `Code retrieved successfully
          Address: ${input.address}
          Code: ${code}
        `);
      } catch (error) {
        return createErrorResponse(`Failed to get code: ${(error as Error).message}`);
      }
    };
  • The input schema definition for the 'provider_get_code' tool, specifying required 'address' and optional 'blockTag'.
    {
      name: "provider_get_code",
      description: "Get the code at an address",
      inputSchema: {
        type: "object",
        properties: {
          address: { type: "string", description: "The address to get code from" },
          blockTag: { type: "string", description: "Optional block tag (latest, pending, etc.)" }
        },
        required: ["address"]
      }
    },
  • src/tools.ts:556-608 (registration)
    Registration of the 'provider_get_code' handler function in the central handlers dictionary.
    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
    };
  • src/tools.ts:425-436 (registration)
    Registration of the 'provider_get_code' tool name and schema in the tools array.
    {
      name: "provider_get_code",
      description: "Get the code at an address",
      inputSchema: {
        type: "object",
        properties: {
          address: { type: "string", description: "The address to get code from" },
          blockTag: { type: "string", description: "Optional block tag (latest, pending, etc.)" }
        },
        required: ["address"]
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get the code at an address' but does not clarify what 'code' entails (e.g., smart contract bytecode, script data), whether it's a read-only operation, potential errors, or rate limits. This lack of detail is a significant gap for a tool with no annotation coverage.

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

Conciseness5/5

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

The description is a single, concise sentence ('Get the code at an address') that is front-loaded and wastes no words. It efficiently communicates the core action without unnecessary elaboration, earning full marks for conciseness.

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

Completeness2/5

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

Given the complexity of blockchain operations, no annotations, and no output schema, the description is incomplete. It lacks details on what 'code' means, expected return values, error conditions, or how it differs from sibling tools, making it inadequate for an agent to use this tool effectively without additional context.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters ('address' and 'blockTag') with descriptions. The description does not add any additional meaning beyond what the schema provides, such as format examples or constraints, but the high schema coverage justifies a baseline score of 3.

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

Purpose4/5

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

The description 'Get the code at an address' clearly states the verb ('Get') and resource ('code at an address'), making the purpose understandable. However, it does not explicitly differentiate from sibling tools like 'provider_get_storage_at' or 'provider_get_transaction', which might retrieve different data types from addresses, leaving some ambiguity in sibling context.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. For example, it does not specify if this is for retrieving smart contract bytecode or other code types, nor does it mention any prerequisites or contexts, leaving the agent to infer usage from the tool name alone.

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

Install Server

Other Tools

Related Tools

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