Skip to main content
Glama

get_erc1155_balance

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);

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