get_erc1155_token_uri
Retrieve the metadata URI for a specific ERC1155 token, which points to JSON data about the token's properties, including its contract address and ID, across Ethereum-compatible networks.
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:148-165 (handler)The main handler function that implements the logic to fetch the ERC1155 token URI by calling the contract's 'uri' method using viem's getContract and read functionality./** * Get ERC1155 token URI */ 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/services/tokens.ts:67-76 (helper)The ABI definition used by the handler to interact with the ERC1155 contract's uri function.// Standard ERC1155 ABI (minimal for reading) const erc1155Abi = [ { inputs: [{ type: 'uint256', name: 'id' }], name: 'uri', outputs: [{ type: 'string' }], stateMutability: 'view', type: 'function' } ] as const;