fetchNftContractDataByMultichainAddress
Retrieve NFT contract data across multiple blockchain networks using wallet addresses. Specify networks like 'eth-mainnet' or 'base-mainnet' and include metadata as needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| addresses | Yes | A list of wallet address and network pairs | |
| withMetadata | No | Whether to include metadata in the results. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"addresses": {
"description": "A list of wallet address and network pairs",
"items": {
"additionalProperties": false,
"properties": {
"address": {
"description": "The wallet address to query. e.g. \"0x1234567890123456789012345678901234567890\"",
"type": "string"
},
"networks": {
"default": [
"eth-mainnet"
],
"description": "The blockchain networks to query. e.g. [\"eth-mainnet\", \"base-mainnet\"]",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"address"
],
"type": "object"
},
"type": "array"
},
"withMetadata": {
"default": true,
"description": "Whether to include metadata in the results.",
"type": "boolean"
}
},
"required": [
"addresses"
],
"type": "object"
}
Implementation Reference
- index.ts:287-312 (registration)Tool registration with inline Zod input schema and thin async handler function that calls the helper and handles response/error formatting.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 }; } });
- api/alchemyApi.ts:138-151 (handler)Core handler implementation that creates an NFT API client and performs POST request to '/by-address' endpoint to fetch NFT contract data.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:288-292 (schema)Zod schema defining the input parameters for the tool.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.'),
- types/types.d.ts:66-69 (schema)TypeScript interface defining the parameter shape used in the alchemyApi handler.export interface NftContractsByAddressParams { addresses: AddressPair[]; withMetadata: boolean; }
- types/types.d.ts:88-91 (helper)Supporting type for address-network pairs used in params.export interface AddressPair { address: string; networks: string[]; }