Metadata is not returned properly by getTokenIdMetadata function

Hi, I have a production app (deployed on bsc mainnet) and currently it experience some issues with nft metadata. They are null right now, but couple days everything worked fine, suddenly yesterday evening stopped working as expected. Should I somehow resync those data or is there any other known solution how to fix this. Probably this method getTokenIdMetadata returns wrong metadata. tokenUri returned by this method is a fine. File with metadata is accesible, but metadata field is still null.

Here is example response which represents this issue:

{
  "token_address": "0x65f006ab6bcaaab15986f6e131dcc21210fac068",
  "token_id": "12",
  "amount": "1",
  "owner_of": "0x9aad909c83656c544b38291f48889bb894c59059",
  "block_number": "13058145",
  "block_number_minted": "13056224",
  "contract_type": "ERC721",
  "name": "VMint NFT Token",
  "symbol": "VMint",
  "token_uri": "https://ipfs.moralis.io:2053/ipfs/QmVVkz2feof25FXhDfzo5dvhWF6XJiMsrHC5cpWKUZXVH8",
  "metadata": null,
  "is_valid": 0,
  "syncing": 2,
  "synced_at": "2021-12-02T19:26:12.744Z",
  "frozen": 0
}

I appreciate quick help as my app is already accessible by our users.

Another issue. Now I cannot fetch any data about following nft, but nft was perfectly minted on blockchain side:

https://bscscan.com/tx/0x33af190dbb9f41599dead9075fb1773eff561c8b620300fa453a7e1488b420b7

Moralis.Cloud.define('getMetadata', async (req) => {
  const res = await Moralis.Web3API.token.getTokenIdMetadata({
    chain: '0x38',
  	address: '0x65f006ab6bcaaab15986f6e131dcc21210fac068',
  	token_id: '30'
  });
 
  return res;
});
{
  "message": "No metadata found! Try again later",
  "name": "Error",
  "stack": "Error: No metadata found! Try again later\n    at handleError (https://slui0lqghrgd.usemoralis.com:2083/bundles/dashboard.bundle.js:97:199328)\n    at async eval (eval at <anonymous> (https://slui0lqghrgd.usemoralis.com:2083/bundles/dashboard.bundle.js:110:1142069), <anonymous>:9:35)"
}

Hi, if the metadata is null it’s best to resolve it yourself using the token_uri

Metadata can be null if we still haven’t indexed it
We are working on improving our systems to be able to index faster to keep up

So I would

  1. Check if metadata is present - if yes - it saves you load time and you can instantly use it
  2. If no - you have to resolve token_uri to get metadata

we are constantly working to improve metadata coverage, soon we hope for most tokens it will be resolved always out of the box

Thanks @ivan you just confirmed my solution to the problem. Thanks for the response.

1 Like