Where is the NFT metadata json linked?

I’m doing an overall explainer of ENS and want to start at the beginning: the NFT itself that shows on the wallet. AFAIK this is the link for the contract: https://etherscan.io/token/0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85

It does not however have a tokenURI function, which is often used to store the json file that will have the image representing the NFT. Where does that data live? Of course the images of your profile are pulled from other NFTs or links, but the image composite, including the name and logo, is stored somewhere too. Where?

2 Likes

My understanding is that it is not stored anywhere. Instead, integrating clients/dapps need to know to call the ENS metadata service to get the NFT image that would have been retrieved via tokenURI. For example: https://metadata.ens.domains/mainnet/0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85/69845409642262400928105080645461410625829953013136762866921256534530425483455/image

That is a centralized service obviously, so the ENS name “NFT image” is dependent on some running server. The metadata service also in turn is dependent on Infura, which is known to run into problems from time to time.

That same metadata service can be used to retrieve the avatar image too (without the ENS overlay). Example: https://metadata.ens.domains/mainnet/avatar/matoken.eth
Another “gotcha” that client/dapp developers run into is that in many cases they can’t just resolve the avatar record and use it. If it’s an IPFS URL, that will usually not render inside of a browser <img> tag. And if it’s that special NFT string, obviously that won’t work directly either.

The metadata service detects when the avatar record is a reference to an NFT, then invokes tokenURI on that NFT contract via Infura and gets the actual image. It’s more complex than it seems too, because unfortunately contracts have a wide variety of ways in which they “support” the tokenURI metadata, and in many cases the format they use isn’t technically correct. The image might also not be just a regular HTTP/IPFS URL, it might be an on-chain data: URL too, which may or may not further be Base64 encoded, etc. If the final URL is IPFS/IPNS, it’s also prefixed with the ipfs.io gateway service so that it’ll actually be able to render in browsers. I could go on with other special cases…

Anyway the metadata service tries to iron out edge cases like that and make it simple for clients to retrieve the avatar / NFT image.

1 Like

1 Like

Thank you! I did not know the metadata had to be manually added by clients so the names can be rendered!

1 Like

The official URL for the metadata service is https://metadata.ens.domains/, but as @serenae observes, it’s not embedded in the contract.

1 Like