is_contract
Verify if an address is a smart contract or an externally owned account (EOA) on Ethereum and EVM-compatible networks using a unified interface.
Instructions
Check if an address is a smart contract or an externally owned account (EOA)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | The wallet or contract address or ENS name to check (e.g., '0x1234...' or 'uniswap.eth') | |
| network | No | Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet. |
Implementation Reference
- src/core/services/contracts.ts:46-53 (handler)The core handler function that implements the logic to check if a given address or ENS name corresponds to a contract by retrieving and checking its bytecode. Returns true if bytecode exists and is not empty ('0x'), false otherwise.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.getBytecode({ address }); return code !== undefined && code !== '0x'; }