Skip to main content
Glama

get_erc1155_balance

Retrieve the balance of a specific ERC1155 token ID owned by a wallet address across Ethereum-compatible networks. Input includes token contract address, token ID, and wallet address.

Instructions

Get the balance of a specific ERC1155 token ID owned by an address. ERC1155 allows multiple tokens of the same ID, so the balance can be greater than 1.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoNetwork name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. ERC1155 tokens exist across many networks. Defaults to Ethereum mainnet.
ownerAddressYesThe wallet address to check the token balance for (e.g., '0x1234...')
tokenAddressYesThe contract address of the ERC1155 token collection (e.g., '0x76BE3b62873462d2142405439777e971754E8E77')
tokenIdYesThe ID of the specific token to check the balance for (e.g., '1234')

Implementation Reference

  • MCP tool handler that takes input parameters, calls the getERC1155Balance service, formats the balance response as JSON, or returns an error message.
    async ({ contractAddress, tokenId, address, network = "ethereum" }) => {
      try {
        const balance = await services.getERC1155Balance(contractAddress as Address, address as Address, BigInt(tokenId), network);
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              network,
              contract: contractAddress,
              tokenId,
              owner: address,
              balance: balance.toString()
            }, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error fetching ERC1155 balance: ${error instanceof Error ? error.message : String(error)}` }],
          isError: true
        };
      }
    }
  • Zod input schema defining parameters for the get_erc1155_balance tool: contractAddress, tokenId, address, and optional network.
    inputSchema: {
      contractAddress: z.string().describe("The ERC1155 contract address"),
      tokenId: z.string().describe("The token ID"),
      address: z.string().describe("The owner address or ENS name"),
      network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
    },
  • Registration of the get_erc1155_balance tool with the server, including description, input schema, annotations, and handler function.
    server.registerTool(
      "get_erc1155_balance",
      {
        description: "Get ERC1155 token balance for an address",
        inputSchema: {
          contractAddress: z.string().describe("The ERC1155 contract address"),
          tokenId: z.string().describe("The token ID"),
          address: z.string().describe("The owner address or ENS name"),
          network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
        },
        annotations: {
          title: "Get ERC1155 Balance",
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true
        }
      },
      async ({ contractAddress, tokenId, address, network = "ethereum" }) => {
        try {
          const balance = await services.getERC1155Balance(contractAddress as Address, address as Address, BigInt(tokenId), network);
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                network,
                contract: contractAddress,
                tokenId,
                owner: address,
                balance: balance.toString()
              }, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error fetching ERC1155 balance: ${error instanceof Error ? error.message : String(error)}` }],
            isError: true
          };
        }
      }
    );
  • Helper function implementing the core logic for fetching ERC1155 token balance using readContract and ERC1155 ABI, supporting ENS resolution.
    export async function getERC1155Balance(
      tokenAddressOrEns: string,
      ownerAddressOrEns: string,
      tokenId: bigint,
      network = 'ethereum'
    ): Promise<bigint> {
      // Resolve ENS names to addresses if needed
      const tokenAddress = await resolveAddress(tokenAddressOrEns, network);
      const ownerAddress = await resolveAddress(ownerAddressOrEns, network);
      
      return readContract({
        address: tokenAddress,
        abi: erc1155Abi,
        functionName: 'balanceOf',
        args: [ownerAddress, tokenId]
      }, network) as Promise<bigint>;
    } 
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it explains ERC1155's multi-token nature (balance can be >1), it doesn't describe the tool's behavior: whether it's a read-only query, what permissions are needed, potential rate limits, error conditions, or what format the balance returns. For a tool with no annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two clear sentences. The first sentence states the core purpose, and the second adds important context about ERC1155's multi-token nature. There's no wasted language, and the information is front-loaded. It could potentially be slightly more structured but is efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description provides basic purpose and ERC1155 context but lacks behavioral details needed for complete understanding. It covers what the tool does but not how it behaves, what it returns, or potential limitations. For a tool with rich parameter schema but no other structured data, the description is minimally adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all 4 parameters. The description doesn't add any parameter-specific information beyond what's in the schema. It mentions ERC1155 context generally but doesn't provide additional semantic details about parameter usage, constraints, or relationships. Baseline 3 is appropriate when schema does complete documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get the balance'), resource ('ERC1155 token ID'), and target ('owned by an address'). It distinguishes from siblings like 'get_nft_balance' by specifying ERC1155 tokens and explaining their multi-token nature. The explanation about ERC1155 allowing multiple tokens of the same ID provides important differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying ERC1155 tokens, but doesn't explicitly state when to use this tool versus alternatives like 'get_nft_balance', 'get_erc20_balance', or 'get_token_balance'. It mentions ERC1155's unique multi-token capability, which hints at usage scenarios, but lacks explicit guidance on tool selection among the many balance-related siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/mcpdotdirect/evm-mcp-server'

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