Skip to main content
Glama

get_erc1155_balance

Read-onlyIdempotent

Retrieve ERC1155 token balance for a specific address and token ID on EVM-compatible blockchains to verify ownership and track multi-token assets.

Instructions

Get ERC1155 token balance for an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe ERC1155 contract address
tokenIdYesThe token ID
addressYesThe owner address or ENS name
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.

Implementation Reference

  • MCP server.tool registration and handler for 'get_erc1155_balance', including input schema validation with Zod and the execution logic that delegates to services.getERC1155Balance.
      'get_erc1155_balance',
      '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.',
      {
        tokenAddress: z
          .string()
          .describe(
            "The contract address of the ERC1155 token collection (e.g., '0x76BE3b62873462d2142405439777e971754E8E77')"
          ),
        tokenId: z
          .string()
          .describe(
            "The ID of the specific token to check the balance for (e.g., '1234')"
          ),
        ownerAddress: z
          .string()
          .describe(
            "The wallet address to check the token balance for (e.g., '0x1234...')"
          ),
        network: z
          .string()
          .optional()
          .describe(
            "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. ERC1155 tokens exist across many networks. Defaults to Ethereum mainnet."
          )
      },
      async ({ tokenAddress, tokenId, ownerAddress, network = 'ethereum' }) => {
        try {
          const balance = await services.getERC1155Balance(
            tokenAddress as Address,
            ownerAddress as Address,
            BigInt(tokenId),
            network
          );
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(
                  {
                    contract: tokenAddress,
                    tokenId,
                    owner: ownerAddress,
                    network,
                    balance: balance.toString()
                  },
                  null,
                  2
                )
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error fetching ERC1155 token balance: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Core helper function getERC1155Balance that resolves addresses (including ENS), reads the ERC1155 contract's balanceOf function, and returns the raw balance as bigint.
    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>;
    } 
  • Registration of EVMTools (which includes get_erc1155_balance) on the MCP server instance.
    registerEVMResources(server);
    registerEVMTools(server);
    registerEVMPrompts(server);
Behavior3/5

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

Annotations cover key behavioral traits: readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=true, indicating a safe, repeatable query. The description adds no behavioral context beyond this, such as rate limits, error conditions, or return format details. However, it doesn't contradict annotations, so it meets the lower bar with annotations present.

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

Conciseness5/5

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

The description is a single, direct sentence with no wasted words, front-loading the core purpose ('Get ERC1155 token balance for an address'). It efficiently communicates the essential action without redundancy or unnecessary elaboration, making it easy for an agent to parse quickly.

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?

For a read-only query tool with rich annotations (readOnlyHint, idempotentHint) and full schema coverage, the description is minimally adequate. However, without an output schema, it doesn't explain return values (e.g., balance format, error responses), and it lacks usage context compared to siblings. This leaves gaps in fully guiding the agent.

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%, with clear descriptions for all parameters (e.g., contractAddress, tokenId, address, network). The description adds no additional semantic context beyond the schema, such as explaining ERC1155-specific nuances or format requirements. Given the high schema coverage, the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the verb ('Get') and resource ('ERC1155 token balance for an address'), making the purpose immediately understandable. It distinguishes from siblings like 'get_balance' (likely for native tokens) and 'get_token_balance' (likely for ERC20 tokens) by specifying ERC1155, though it doesn't explicitly contrast with them.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_balance' or 'get_token_balance'. It doesn't mention prerequisites, such as needing a valid contract address or network, or specify use cases like checking NFT holdings. This leaves the agent to infer usage from the tool name alone.

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

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

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