validate-ethereum-address
Verify the correctness of an Ethereum address using the Blockchain MCP Server tool, ensuring it meets the required format and standards.
Instructions
Validate the validity of an Ethereum address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Ethereum address to validate |
Implementation Reference
- src/vanity-address/generator.ts:86-109 (handler)The handler function for the 'validate-ethereum-address' tool. It uses ethers.isAddress(address) to validate the Ethereum address, computes the checksummed version if valid, and returns a formatted text response indicating validity.async ({ address }) => { try { const isValid = ethers.isAddress(address); const checksumAddress = isValid ? ethers.getAddress(address) : null; return { content: [{ type: "text", text: `Address validation result: 🔹 Original Address: ${address} 🔹 Valid: ${isValid ? '✅ Valid' : '❌ Invalid'} ${checksumAddress ? `🔹 Checksum Address: ${checksumAddress}` : ''}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error validating address: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- The input schema for the 'validate-ethereum-address' tool, defining the 'address' parameter using Zod.{ title: "Validate Ethereum Address", description: "Validate the validity of an Ethereum address", inputSchema: { address: z.string().describe("Ethereum address to validate") } },
- src/vanity-address/generator.ts:77-110 (registration)Registration of the 'validate-ethereum-address' tool on the McpServer, including schema and inline handler function.server.registerTool( "validate-ethereum-address", { title: "Validate Ethereum Address", description: "Validate the validity of an Ethereum address", inputSchema: { address: z.string().describe("Ethereum address to validate") } }, async ({ address }) => { try { const isValid = ethers.isAddress(address); const checksumAddress = isValid ? ethers.getAddress(address) : null; return { content: [{ type: "text", text: `Address validation result: 🔹 Original Address: ${address} 🔹 Valid: ${isValid ? '✅ Valid' : '❌ Invalid'} ${checksumAddress ? `🔹 Checksum Address: ${checksumAddress}` : ''}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error validating address: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );