I'm trying to call api.query.nfts.itemMetaDataOf<type>(collection_id, token_id); via typescript and polkadotjs.

It's not clear which type I'm supposed to use for the response. At least I can't find any suitable type in @polkadot/types-codec.

1 Answer 1


You can manually generate the types of your chain using typegen. You have to point to the WS address of your chain to download the metadata, and derive custom types from it. Here is the example project.

In your case, it would probably look like this (after you have generated custom types):

import { PalletNftsItemMetadata } from "./lookup";

let itemMetadata = await api.query.nfts.itemMetadataOf<PalletNftsItemMetadata>(
  • That works indeed. The only issue I have is that, when trying to import the type, I get the error: ``` Module '"../../interfaces/lookup"' has no exported member 'PalletNftsItemMetadata'. Did you mean to use 'import PalletNftsItemMetadata from "../../interfaces/lookup"' instead? ``` It's strange, because PalletNftsItemMetadata is under export default. Commented Jan 23 at 10:24
  • yeah, it could be the case. Did you also include the new types/interfaces in the tsconfig.json? If you have included them, they should be available from normal @polkadot/types package
    – dastansam
    Commented Jan 23 at 13:19
  • Yes, I followed the instructions and added paths to tsconfig.json: "paths": { // this is the package name we use (in the interface imports, --package for generators) "incentiverse/*": ["./src/*"], // here we replace the @polkadot/api augmentation with our own, generated from chain "@polkadot/api/augment": ["./src/interfaces/augment-api.ts"], // replace the augmented types with our own, as generated from definitions "@polkadot/types/augment": ["./src/interfaces/augment-types.ts"] } Commented Jan 23 at 14:01
  • Also trying to import as import type { PalletNftsItemMetadata } from '@polkadot/types'; results in the same no exported member error. Commented Jan 23 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.