Skip to main content
Glama

eth_getCode

Retrieve the deployed bytecode of any smart contract using its address. Works across 30+ Ethereum networks via Infura.

Instructions

Get the deployed bytecode of a smart contract.

Args:

  • contractAddress (string): Contract address (20-byte hex, e.g., '0x...').

  • network (string, optional): Ethereum network to query. Defaults to 'mainnet'.

Returns:

  • Hexadecimal string containing the contract bytecode. Returns '0x' if address is not a contract or has no code.

Examples:

  • "Get USDT contract code": { "contractAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7" }

  • "Check Sepolia contract": { "contractAddress": "0x...", "network": "sepolia" }

Errors:

  • InvalidParams: When contractAddress format is invalid.

  • InternalError: When Infura API is unavailable or returns an error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe 20-byte contract address to retrieve the code from.
networkNoThe Ethereum network to connect to (e.g., 'mainnet' or 'sepolia').mainnet
response_formatNoOutput format: 'json' for structured data, 'markdown' for human-readable.json
Behavior4/5

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

Describes return format (hex string), error conditions, and that it queries Infura API. However, no mention of authentication or rate limits, though read-only nature is implied.

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?

Well-structured with Args, Returns, Examples, and Errors sections. Every sentence adds useful information without redundancy.

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

Completeness5/5

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

Given no output schema, the description fully explains the return value, covers all parameters, provides examples, and lists possible errors. Sufficient for the tool's complexity.

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?

With 100% schema coverage, baseline is 3. Description adds value by explaining contractAddress format, network defaults, and response_format enum with examples, going beyond what the schema provides.

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?

Description clearly states 'Get the deployed bytecode of a smart contract' with a specific verb and resource. Distinguishes from sibling tools like eth_getBalance and eth_getStorageAt by focusing on deploying code retrieval.

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

Usage Guidelines4/5

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

Provides context with examples and notes on default network and return '0x' for non-contracts, but does not explicitly state when to use this tool over alternatives or when not to use it.

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

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/Qbandev/infura-mcp-server'

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