Clearing up a common misconception about NFTs
The “right-click save as” argument is frequently cited by people without much experience in the NFT space as a reason to blindly dismiss NFTs as a whole. Critics argue that NFT art is not actually stored on the blockchain, and thus NFTs have no intrinsic value. A little research will show that this argument has shaky foundations, and might not be the best one upon which to base one’s criticisms. In this post I’ll show how NFT projects can exist fully on-chain, and ways you can inspect those on-chain assets for yourself.
I recently minted an NFT. Like many NFTs, it has an image associated with it. Unlike NFTs that store their image data off-chain on an external server, this one stores its image data on-chain. Let’s take a look at the underlying code to see how this works.
Using Etherscan, we can see the smart contract for my NFT. If you scroll down to the tokenURI section, enter the token ID (61), and click the Query button, you will be able to see the Uniform Resource Identifier (URI) for my token. The URI either specifies the location of the data to be associated with an NFT on an external site, or consists of the data itself, which is the case here. This URI will look like complete gibberish, because it’s encoded in Base64.
We can decode the tokenURI data for the NFT on https://www.base64decode.net. If I copy and paste the Base64-encoded data from the token into the website, I can get a better sense of what that data represents. Let’s see what we have:
Here we can see that the NFT data exists on the blockchain, rather than on an external site. It has a name, a description, and an attribute named “Love” with a value of 16. There’s also more Base64 data! There are hints in this data as to how we should interpret it. Those hints are used both by people and software when it comes time to decide how to process a given blob of data.
The “data:image/svg+xml;base64” prefix tells us that this data should be interpreted as an image, in a graphics file format known as SVG (Scalable Vector Graphics) that is written in XML (Extensible Markup Language). The SVG format allows resizing of an image without loss in resolution. If you’ve ever tried scaling an image that uses a Vector format (such as a .jpeg or .png file), you’ll know that the results are generally pretty pixelated and terrible looking. XML is another language that both humans and machines can read, and much readily than Base64.
So, taking what we already know, let’s copy this hidden Base64-encoded data we just uncovered (not including the “data:image/svg+xml;base64” prefix) and paste in back into the same Base64 decoding website as before. Here is the result:
Let’s take a minute to orient ourselves here. So far we’ve located a specific NFT token on the blockchain, extracted the data it contained, and decoded it into a format that we can somewhat understand. We know it’s an entity that has a name, a description, an attribute named “Love” with a value of 16, and an image that is associated with it. When we decoded the image data, we found something that’s more readable, but not by much.
Next time we’ll explore the svg image format in more depth, and see how we can go from a confusing-looking blob of code to something more visually appealing.
Until then, stay safe in the metaverse!