Skip to main content
Glama

is_contract

Verify whether a given address is a smart contract or an externally owned account (EOA) on supported networks, including BSC, Ethereum, and more.

Instructions

Check if an address is a smart contract or an externally owned account (EOA)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe wallet or contract address to check
networkNoNetwork name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet.bsc

Implementation Reference

  • MCP tool registration for 'is_contract', including input schema (address, network), handler logic using services.isContract, and response formatting.
    server.tool( "is_contract", "Check if an address is a smart contract or an externally owned account (EOA)", { address: z.string().describe("The wallet or contract address to check"), network: defaultNetworkParam }, async ({ address, network = "bsc" }) => { try { const isContract = await services.isContract( address as Address, network ) return mcpToolRes.success({ address, network, isContract, type: isContract ? "Contract" : "EOA" }) } catch (error) { return mcpToolRes.error(error, "checking contract status") } } )
  • Core helper function isContract that resolves ENS if needed, fetches bytecode using viem public client, and determines if it's a contract (non-empty code).
    /** * Check if an address is a contract * @param addressOrEns Address or ENS name to check * @param network Network name or chain ID * @returns True if the address is a contract, false if it's an EOA */ export async function isContract( addressOrEns: string, network = "ethereum" ): Promise<boolean> { // Resolve ENS name to address if needed const address = await resolveAddress(addressOrEns, network) const client = getPublicClient(network) const code = await client.getCode({ address }) return code !== undefined && code !== "0x" }
  • Module-level registration call to registerContractTools, which includes the 'is_contract' tool.
    registerContractTools(server)
  • src/evm/index.ts:13-13 (registration)
    EVM module registration that includes contracts tools like 'is_contract'.
    registerContracts(server)

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/bnb-chain/bnbchain-mcp'

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