is_contract
Determine if an Arbitrum address represents a smart contract by checking its code storage. This tool helps verify contract existence for interactions and security assessments on Arbitrum networks.
Instructions
Check if an address is a contract
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rpcUrl | No | The RPC URL of the chain (optional if default is set) | |
| address | Yes | Address to check |
Implementation Reference
- src/index.ts:306-322 (handler)Handler for the 'is_contract' MCP tool. Resolves RPC URL, creates EthereumAccountClient instance, calls isContract(address), and returns whether the address is a contract.case "is_contract": { const rpcUrl = await this.resolveRpcUrl( (args.rpcUrl as string) || (args.chainName as string) ); const ethereumAccountClient = new EthereumAccountClient(rpcUrl); const isContract = await ethereumAccountClient.isContract( args.address as string ); return { content: [ { type: "text", text: `Is contract: ${isContract}`, }, ], }; }
- src/index.ts:1020-1037 (schema)Input schema definition for the 'is_contract' tool, specifying parameters rpcUrl (optional) and address (required). Part of the tools list returned by list tools request.name: "is_contract", description: "Check if an address is a contract", inputSchema: { type: "object" as const, properties: { rpcUrl: { type: "string", description: "The RPC URL of the chain (optional if default is set)", }, address: { type: "string", description: "Address to check", }, }, required: ["address"], }, },
- src/index.ts:1020-1037 (registration)Tool registration in the getAvailableTools() method, which defines the 'is_contract' tool name, description, and schema for the MCP list tools endpoint.name: "is_contract", description: "Check if an address is a contract", inputSchema: { type: "object" as const, properties: { rpcUrl: { type: "string", description: "The RPC URL of the chain (optional if default is set)", }, address: { type: "string", description: "Address to check", }, }, required: ["address"], }, },
- Core helper function in EthereumAccountClient that implements the contract check logic by fetching bytecode via getCode and checking if it's non-empty ('0x'). Called by the tool handler.async isContract(address: string): Promise<boolean> { const code = await this.getCode(address); return code !== '0x'; }