resolveName
Resolve ENS names to Ethereum addresses using the MCP Ethers Wallet server. Specify the ENS name and optionally the network or chain ID for accurate resolution across Ethereum networks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | No | Optional. The chain ID to use. If provided with a named network and they don't match, the RPC's chain ID will be used. | |
| name | Yes | The ENS name to resolve | |
| provider | No | Optional. Either a network name or custom RPC URL. Use getAllNetworks to see available networks and their details, or getNetwork to get info about a specific network. You can use any network name returned by these tools as a provider value. |
Implementation Reference
- src/tools/core.ts:743-783 (handler)Executes the resolveName tool logic: gets an ethers provider based on provider/chainId, calls provider.resolveName(name) to resolve ENS name to Ethereum address, returns structured JSON response with success/failure.async ({ name, provider, chainId }) => { try { const ethProvider = await ethersService.getProvider(provider, chainId); // Resolve the ENS name to an address const address = await ethProvider.resolveName(name); if (!address) { return { content: [{ type: "text", text: JSON.stringify({ name, resolved: false, message: "Name could not be resolved" }, null, 2) }] }; } return { content: [{ type: "text", text: JSON.stringify({ name, address, resolved: true }, null, 2) }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error resolving ENS name: ${error instanceof Error ? error.message : String(error)}` }] }; } } );
- src/tools/core.ts:734-742 (schema)Zod schema for input parameters of resolveName tool: name (string, required), provider (string, optional), chainId (number, optional).{ name: z.string().describe( "The ENS name to resolve" ), provider: z.string().optional().describe(PROVIDER_DESCRIPTION), chainId: z.number().optional().describe( "Optional. The chain ID to use. If provided with a named network and they don't match, the RPC's chain ID will be used." ) },
- src/tools/core.ts:731-783 (registration)Direct registration of the resolveName tool using server.tool() within registerCoreTools function, including inline schema and handler.// ENS resolveName tool server.tool( "resolveName", { name: z.string().describe( "The ENS name to resolve" ), provider: z.string().optional().describe(PROVIDER_DESCRIPTION), chainId: z.number().optional().describe( "Optional. The chain ID to use. If provided with a named network and they don't match, the RPC's chain ID will be used." ) }, async ({ name, provider, chainId }) => { try { const ethProvider = await ethersService.getProvider(provider, chainId); // Resolve the ENS name to an address const address = await ethProvider.resolveName(name); if (!address) { return { content: [{ type: "text", text: JSON.stringify({ name, resolved: false, message: "Name could not be resolved" }, null, 2) }] }; } return { content: [{ type: "text", text: JSON.stringify({ name, address, resolved: true }, null, 2) }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error resolving ENS name: ${error instanceof Error ? error.message : String(error)}` }] }; } } );
- src/tools/index.ts:23-23 (registration)Top-level registration call to registerCoreTools in registerAllTools, which registers the resolveName tool among core tools.registerCoreTools(server, ethersService);