NFT MetaData not returned because wrong token_uri

Check out below response msg, no metadata returned because there’s a bug on token_uri.
It should be https://sunflower-land.com/play/erc1155/204.json

request:

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/0xC159698C6BD7422a9DBDEDc848fF6d35A15Fa689/nft?chain=polygon&format=decimal' \
  -H 'accept: application/json' \

part of response

{
      "token_address": "0x22d5f9b75c524fec1d6619787e582644cd4d7422",
      "token_id": "204",
      "block_number_minted": "25433916",
      "owner_of": "0xc159698c6bd7422a9dbdedc848ff6d35a15fa689",
      "block_number": "27518134",
      "token_hash": "77cabf5efe50032a20e20c14f27ae728",
      "amount": "1000000000000000000",
      "contract_type": "ERC1155",
      "name": null,
      "symbol": null,
      "token_uri": "https://sunflower-land.com/play/erc1155/00000000000000000000000000000000000000000000000000000000000000cc.json",
      "metadata": null,
      "synced_at": "2022-04-21T00:15:09.818Z"    },

Token uri is correct. It is the hex form of the 204 number.

Try to resync the metadata with resyncmetadata function.
https://docs.moralis.io/moralis-dapp/web3-sdk/token#resyncmetadata

No one would use hex form of token ID (and with so many 0s ) to name a file of metadata.
“00000000000000000000000000000000000000000000000000000000000000cc.json”
“204.json”
Resync did not solve the problem.
Code change must be done about the token_uri assemble.
This is actually a CRITICAL ISSUE.

other similar cases:

"token_uri": "https://gateway.moralisipfs.com/ipfs/QmaqkBj1LSbPPDURbgzKfMWvAjWZZoeabYigUa7n4Xm4ts/000000000000000000000000000000000000000000000000000000000000666e.json"

what is the exact issue that you thing that is happening here?

hex(204) = 0xcc, that is how ERC1155 token_uri standard works, it uses the hex value in the token uri

I see. You are right. It is recommended to use hex value to replace id in token uri.
What we are doing is to build a NFT exchanging market.
We met several ERC1155 contracts that use dec value in token uri.
We can’t get metadata for these contracts by using moralis NFT API.
e.g.



can you paste specific contract address and token id where it doesn’t work?
also, if you can extract the token_uri directly from chain for that particular token id and contract

As I posted before:
Polygon
Contract: 0x22d5f9b75c524fec1d6619787e582644cd4d7422
TokenID:204
The actual token uri is:https://sunflower-land.com/play/erc1155/204.json
but not:
https://sunflower-land.com/play/erc1155/00000000000000000000000000000000000000000000000000000000000000cc.json
Thank you for your replies.
And I understand that this issue is caused by the “incorrect” implementation of ERC1155.
Moralis NFT API works as expected according to the standard of ERC1155.
At the end as a 3rd party NFT marketplace, we have to give up supporting these kind of ERC1155 NFT implementation.

This is the token_uri returned from the contract: https://sunflower-land.com/play/erc1155/{id}.json

You could ask that NFT marketplace to fix the final token uri and after that it should work.

Moralis now supports refresh for all NFTs automatically Moralis Updates NFT Metadata