Skip to main content
Glama

parseEther

Convert ether values from human-readable strings to precise Wei units for blockchain transactions and calculations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
etherYesThe ether value to parse

Implementation Reference

  • The main handler function for the 'parseEther' MCP tool. It takes an ether amount as a string, uses ethers.parseEther to convert it to wei (bigint), and returns the wei value as a string.
        try {
          const weiValue = ethers.parseEther(ether);
          
          return {
            content: [{ 
              type: "text", 
              text: weiValue.toString()
            }]
          };
        } catch (error) {
          return {
            isError: true,
            content: [{ 
              type: "text", 
              text: `Error parsing ether: ${error instanceof Error ? error.message : String(error)}`
            }]
          };
        }
      }
    );
  • Zod input schema for the parseEther tool, defining the 'ether' parameter as a string.
      ether: z.string().describe(
        "The ether value to parse"
      )
    },
    async ({ ether }) => {
  • Registration of the parseEther tool using server.tool() within registerCoreTools function.
    "parseEther",
  • Helper usage of ethers.parseEther inside sendTransaction tool.
    value: ethers.parseEther(value),
  • Helper usage of ethers.parseEther inside sendTransactionWithOptions tool.
    value: ethers.parseEther(value),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/crazyrabbitLTC/mcp-ethers-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server