is_contract
Verify if a given address is a smart contract on Arbitrum chains. Input the address and optional RPC URL to determine its contract status efficiently.
Instructions
Check if an address is a contract
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Address to check | |
| rpcUrl | No | The RPC URL of the chain (optional if default is set) |
Implementation Reference
- src/index.ts:306-322 (handler)MCP tool handler for 'is_contract': resolves RPC URL, creates EthereumAccountClient instance, calls isContract(address), and returns result as text content.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)Tool schema definition for 'is_contract' including input schema with rpcUrl (optional) and address (required). Registered in getAvailableTools().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 method isContract(address) that fetches bytecode via getCode and checks if non-empty (not '0x'). Called by the main handler.async isContract(address: string): Promise<boolean> { const code = await this.getCode(address); return code !== '0x'; }
- Supporting getCode(address) method that makes eth_getCode RPC call, used by isContract.async getCode(address: string): Promise<string> { return await this.makeRpcCall('eth_getCode', [address, 'latest']); }