resyncMetadata() updates token_uri but not metadata

Using the Web3API SDK, it seems that reSyncMetadata resyncs successfully the token_uri but doesn’t refetch the metadata.

Code example below, token_uri is updated but metadata returns the old metadata still.

await Moralis.Web3API.token.reSyncMetadata({
                chain: 'eth',
                address: contract,
                token_id: tokenId.toString(),
                flag: 'uri',
                mode: 'sync',
            })

can you give a specific example of chain, contract address and token id?

Same issue here but from a different API. Here is the example:

const options = {
    address: "0x9401518f4ebba857baa879d9f76e1cc8b31ed197",
    token_id: "1349",
    chain,
  };
  const tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(
    options
  );
  console.log(tokenIdMetadata);

The response is:

{
  token_address: '0x9401518f4ebba857baa879d9f76e1cc8b31ed197',
  token_id: '1349',
  owner_of: '0x1f861b04aba9d12b7d567bd91ae67ee7b9b2f879',
  block_number: '14243279',
  block_number_minted: '14176129',
  token_hash: '2a837535e80ca1bb328bb4bec2746515',
  amount: '1',
  contract_type: 'ERC721',
  name: 'Weirdo Ghost Gang',
  symbol: 'GHOST',
  token_uri: 'https://ipfs.moralis.io:2053/ipfs/QmU61BwmB9fm3kN4EWS14YxrB1FFJcMWj9GRrf4hsEvaYE/1349',
  metadata: `{"name":"Lil Ghost#1349","description":"Weirdo Ghost Genesis is Sleepy's graffiti work, purely hand-drawn, not generated. All the little ghosts came from my dreams, and I was trying to draw the people from my dreams since I was a child.","image":"https://ipfs.io/ipfs/Qmdw2EFVqrKM9rjtRi2yxJT9gFYkmKpEUooiLheVSoXfmK","attributes":"Unpublished"}`,
  synced_at: '2022-02-10T04:13:55.378Z',
  last_token_uri_sync: null,
  last_metadata_sync: null
}

The corresponding metadata from token_uri is

{"name":"Lil Ghost#1349","description":"We are the ghost, your nightmare, your daydream.","image":"https://ipfs.io/ipfs/QmdursSMNaAhQTYJAqWvKdMWM2BCvfYYfRyTnynJu2YFp5","attributes":[{"trait_type":"bg","value":"Wild Watermelon"},{"trait_type":"body","value":"Spirit"},{"trait_type":"clothes","value":"Blue Pajamas"},{"trait_type":"head","value":"Angel Halo"},{"trait_type":"eye","value":"Violet Round"},{"trait_type":"mouth","value":"Mouth 6"}]}

which is different from the metadata fetched.

1 Like

You can use resyncMetadata to force an update of an NFT’s metadata or token_uri.

now it works as expected

@cryptokid I think this is still not working as expected, for example the following data fetched from Moralis API:

{
    token_address: '0x78fd3fa3ce045f59eb8c4dc7c21906295a8e3ab4',
    token_id: '4360',
    amount: '1',
    owner_of: '0x8891075a34b58a53dddf50b8e200211ff470a580',
    token_hash: '48e95a7ee137a3f612673dfcb491d24e',
    block_number_minted: '14809954',
    block_number: '14809954',
    contract_type: 'ERC721',
    name: 'Rich Baby',
    symbol: 'BABY',
    token_uri: 'https://api.rich.baby/api/baby/4360.json',
    metadata: '{"name":"Incubator Pass #4360","description":"A pass to the [Rich Baby Incubator](https://rich.baby/incubator), you can claim a unique baby with this pass during the reveal game.","image":"https://api.rich.baby/pass.png","animation_url":"https://api.rich.baby/pass.mp4","background_color":"000000","attributes":[{"trait_type":"Used","value":"Not yet"}]}',
    synced_at: '2022-05-25T13:20:43.167Z',
    last_token_uri_sync: '2022-05-20T08:13:54.349Z',
    last_metadata_sync: '2022-05-25T13:20:43.167Z'
  }

The token_uri data does not match metadata.

what is the difference, what doesn’t match?
it looks like the image doesn’t match, it can depend on when it was updated, it could have been updated after last_metadata_sync: '2022-05-25T13:20:43.167Z', you can try a resyncMetadata now

It doesn’t seem to be the case. The data in token_uri was the same as few days ago but the metadata field was not updated based on token_uri. Since I have fetched the data a few days ago it should have already be synced with the latest change of auto updated metadata in Moralis. Is it possible to check if there is anything wrong with the Moralis auto sync backend?

1 Like

I found out that for now we are able to update the metadata only when the token_uri points to IPFS. It is too much for now to update all the metadata automatically.

@cryptokid Got it! This is very helpful information for us. If metadata is not updated automatically in some cases, will token_uri be updated automatically if it is changed?

Token uri may not be updated either in those cases now. I’ll have to check with the team.

Thanks! btw if I called resyncMetadata will the token_uri or metadata be updated in the case where the uri is not ipfs?

When you call resyncMetadata it will be updated if it is or not ipfs, when that call is made for resyncMetadata