getNFTsForContract doesn't update metadata

My NFTs have dynamic metadata and I’m using getNFTsForContract method to get user’s NFT. The problem is that the metadata never updates. It’s the same as on the minting.

I know that the metadata is in fact changing because it’s reflecting on OpenSea. But it looks like the getNFTsForContract is using some kind of caching. How to force it to update?

1 Like

If you call getTokenIdMetadata , then in 24 hours Moralis should update the metadata in its internal database for that specific token id.

1 Like

@cryptokid any way to update it more often?

For now I don’t know of a way to update it more often.

Alright, thanks :slight_smile:

I thought metadata lives on-chain, and that Moralis does live updates?! I thought that was the whole point - being able to read directly from the blockchain with Moralis? Or have I misunderstood something?? Live metadata is important to my project, similar to @ApesTogetherStrong 's usecase, by the sound of it :S ??

1 Like

Metadata does not live on-chain, instead off-chain usually in IPFS and the tendency these NFTs are immutable once they’re created therefore most NFT metadata stay constant. Currently Moralis doesn’t resync and update the metadata, but it is a feature that might be added in the future https://docs.moralis.io/misc/faq#why-is-metadata-outdated :raised_hands:

1 Like

Oh I see. But all of the on-chain data is accessible live, correct? Im intending on keeping some metadata ie. JPEG on IPFS, and other metadata like text on-chain, and editable via the contract. This latter information will live update, right?

In the cases where you have the smart contract and you want to update the metadata from time to time, you can extract the metadata from chain, or you can keep a cache with latest metadata.

1 Like

Having the same problems. I’m updating my token URI in the contract but it does not update in the frontend dapp

Using getTokenIdMetadata

did you use the resync endpoint?

https://docs.moralis.io/moralis-server/web3-sdk/token#resyncmetadata

you will have to use it with uri and then with metadata

I have been trying to use this function. But i’m keep getting error. I think it’s due to rate limit.
Would you have an example code to show how it’s run in JS.

1 Like

you can find example here: https://docs.moralis.io/moralis-server/web3-sdk/token#resyncmetadata

you can also call it directly from web3api interface: https://admin.moralis.io/web3Api

you can not call it more then once per second

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

I’m still not able to get metadata updated for a contract I’m pulling. I’ve tried all approaches in this thread:

  • getTokenIdMetadata
  • getTokenIdOwners
  • reSyncMetadata

It was great to see theoretical ‘supports refresh for all NFTs automatically’, but I’ve been calling these endpoints for the past 3 days, and still metadata has never refreshed for the token. Here’s the response from getTokenIdMetadata. Is there anything else I can do to get this to refresh?

amount: "1"
​block_number: "14719796"
block_number_minted: "14719796"
contract_type: "ERC721"
last_metadata_sync: null
last_token_uri_sync: null
metadata: "{\"animation_url\":\"\",\"description\":\"VX Deluxe emerge from the ether to aid Bears Deluxe on their quest into the metaverse. 6,900 1:1 matches to the original Bears Deluxe collection with an additional 3,100 Avatars to join in the adventure. VX Deluxe are fully animated and rigged 3D avatars ready for integration into any 3D game engine. They will also be playable in the Sandbox Game, along with original creations from the Bears Deluxe team.\",\"image\":\"https://bearsdeluxe.mypinata.cloud/ipfs/QmSDommgBGjBCHjmLR49z5Tz6UhBUYdUzaaBEnLD3XzwoB\",\"attributes\":[],\"external_url\":\"https://bearsdeluxe.io\",\"name\":\"VX Deluxe #1355\"}"
name: "VX Deluxe"
owner_of: "0xd62356ab5dafe3c6c741fa8a59479500ab05737a"
symbol: "VX Deluxe"
synced_at: "2022-05-14T02:58:30.276Z"
token_address: "0xaf9f836cc3e4019addd529c2579e44938252a1ae"
token_hash: "8532426fb3b165a134169a65273821fd"
token_id: "1355"
token_uri: "https://bearsdeluxe.mypinata.cloud/ipfs/Qmcd7sGdtEkCp32vv7GUzHfWLN54C4rGn1fJv5uKjEZsGo/1355"

Hello, what should the metadata be for 1355? Is the token_uri correct? The metadata matches what is in https://bearsdeluxe.mypinata.cloud/ipfs/Qmcd7sGdtEkCp32vv7GUzHfWLN54C4rGn1fJv5uKjEZsGo/1355 currently. Metadata updates from the token_uri.

Right, its the token_uri that is incorrect.

The project updated the token_uri during the project reveal. I assumed metadata refresh would pull the latest token_uri from the contract and update with that.

This is the updated URL for that token:
https://bearsdeluxe.mypinata.cloud/ipfs/QmRdgXLpxisJjTSHDmZrYxxTkZVNZNfUf56oMAW15v4T9u/1355

did you try reSyncMetadata with uri flag?

did you try reSyncMetadata with uri flag?

Ok, this worked! Thank you. So will the automatic refresh endpoints not do URI refreshes? Most projects I’m involved with are on IPFS so metadata itself is immutable and cannot refresh. It’s the URI that needs to be updated and refreshed.

the automatic refresh will also handle changes in token uri