fetchNftContractDataByMultichainAddress
Retrieve NFT contract data across multiple blockchain networks using wallet addresses. Query token ownership and metadata from Ethereum, Base, and other supported chains.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| addresses | Yes | A list of wallet address and network pairs | |
| withMetadata | No | Whether to include metadata in the results. |
Implementation Reference
- api/alchemyApi.ts:138-151 (handler)Core handler function that executes the tool logic by calling the Alchemy NFT API to fetch NFT contract data for given multichain addresses.async getNftContractsByAddress(params: NftContractsByAddressParams) { try { const client = createNftClient(); const response = await client.post('/by-address', { ...params }); return response.data; } catch (error) { console.error('Error fetching NFT contracts by address:', error); throw error; } },
- index.ts:287-312 (registration)MCP tool registration including input schema (zod), thin wrapper handler, and error handling.server.tool('fetchNftContractDataByMultichainAddress', { addresses: z.array(z.object({ address: z.string().describe('The wallet address to query. e.g. "0x1234567890123456789012345678901234567890"'), networks: z.array(z.string()).default(['eth-mainnet']).describe('The blockchain networks to query. e.g. ["eth-mainnet", "base-mainnet"]'), })).describe('A list of wallet address and network pairs'), withMetadata: z.boolean().default(true).describe('Whether to include metadata in the results.'), }, async (params) => { try { const result = await alchemyApi.getNftContractsByAddress(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } catch (error) { if (error instanceof Error) { console.error('Error in getNftContractsByAddress:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } return { content: [{ type: "text", text: 'Unknown error occurred' }], isError: true }; } });
- types/types.d.ts:66-69 (schema)TypeScript interface defining the input parameters for the NFT contracts by address query.export interface NftContractsByAddressParams { addresses: AddressPair[]; withMetadata: boolean; }
- api/alchemyClients.ts:61-68 (helper)Helper function to create the Axios client configured for Alchemy's NFT API endpoint.export const createNftClient = () => axios.create({ baseURL: `https://api.g.alchemy.com/data/v1/${API_KEY}/assets/nfts`, headers: { 'accept': 'application/json', 'content-type': 'application/json', 'x-alchemy-client-breadcrumb': BREADCRUMB_HEADER }, });