get_erc1155_token_uri
Retrieve the metadata URI for a specific ERC1155 token by providing its contract address, token ID, and network. The URI links to JSON data detailing the token's attributes and properties.
Instructions
Get the metadata URI for an ERC1155 token (multi-token standard used for both fungible and non-fungible tokens). The URI typically points to JSON metadata about the token.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. ERC1155 tokens exist across many networks. Defaults to Ethereum mainnet. | |
| tokenAddress | Yes | The contract address of the ERC1155 token collection (e.g., '0x76BE3b62873462d2142405439777e971754E8E77') | |
| tokenId | Yes | The ID of the specific token to query metadata for (e.g., '1234') |
Implementation Reference
- src/core/services/tokens.ts:151-165 (handler)Core implementation of the getERC1155TokenURI function using viem's getPublicClient and getContract to call the ERC1155 uri method on the specified tokenId.export async function getERC1155TokenURI( tokenAddress: Address, tokenId: bigint, network: string = 'ethereum' ): Promise<string> { const publicClient = getPublicClient(network); const contract = getContract({ address: tokenAddress, abi: erc1155Abi, client: publicClient, }); return contract.read.uri([tokenId]); }
- src/core/tools.ts:1549-1606 (registration)MCP server.tool registration for 'get_erc1155_token_uri' tool. Includes Zod input schema for parameters (tokenAddress, tokenId, network) and handler logic that calls the core services.getERC1155TokenURI function, formats MCP response.server.tool( 'get_erc1155_token_uri', 'Get the metadata URI for an ERC1155 token (multi-token standard used for both fungible and non-fungible tokens). The URI typically points to JSON metadata about the token.', { 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 query metadata for (e.g., '1234')" ), 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, network = 'ethereum' }) => { try { const uri = await services.getERC1155TokenURI( tokenAddress as Address, BigInt(tokenId), network ); return { content: [ { type: 'text', text: JSON.stringify( { contract: tokenAddress, tokenId, network, uri }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching ERC1155 token URI: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/core/tools.ts:1553-1569 (schema)Zod schema for input validation of the get_erc1155_token_uri tool parameters.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 query metadata for (e.g., '1234')" ), 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." ) },
- src/core/resources.ts:577-579 (helper)Usage of getERC1155TokenURI in EVM resource handler for ERC1155 token metadata URI.const tokenURI = await services.getERC1155TokenURI(tokenAddress, tokenId, network); return {