Skip to main content
Glama

get-native-currency-balance

Retrieve the native cryptocurrency balance for any blockchain address. This tool queries on-chain data to display current holdings without requiring private keys.

Instructions

Get the native currency balance of an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes

Implementation Reference

  • The handler function that executes the tool: casts address, calls wagmi's getBalance with wagmiConfig and address, stringifies the result with JSONStringify, and returns it as text content.
    execute: async (args) => {
      const address = args.address as Address
      const result = await getBalance(wagmiConfig, { address })
      return {
        content: [
          {
            type: "text",
            text: JSONStringify(result),
          },
        ],
      }
    },
  • Zod input schema requiring a single 'address' string parameter.
    parameters: z.object({
      address: z.string()
    }),
  • Registers the 'get-native-currency-balance' tool on the FastMCP server within registerGetBalanceTools function.
    server.addTool({
      name: "get-native-currency-balance",
      description: "Get the native currency balance of an address",
      parameters: z.object({
        address: z.string()
      }),
      execute: async (args) => {
        const address = args.address as Address
        const result = await getBalance(wagmiConfig, { address })
        return {
          content: [
            {
              type: "text",
              text: JSONStringify(result),
            },
          ],
        }
      },
    });
  • Top-level call to registerGetBalanceTools during server initialization, which includes the get-native-currency-balance tool.
    registerGetBalanceTools(server);

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/Xiawpohr/mcpilot'

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