Metadata in NFT assets play a vital role as it contains details making NFT utility possible. That said, there are different aspects developers must consider when wanting to use the data. For example, when creating NFTs, you must use suitable NFT metadata storage solutions. Also, you need to go with the correct metadata format. Nonetheless, knowing what information you can find in metadata for NFT assets is also pretty important.
In addition to properly understanding metadata in NFT assets, you also want to equip yourself with the best tools. This is where the ultimate NFT API makes all development endeavors feel like a breeze. The API provides powerful endpoints to fetch all sorts of on-chain data with short code snippets. Consequently, it’s the most important tool when building NFT dapps. Of course, the best NFT API also lets you fetch metadata NFT content. This means you can display NFT-representing files, incorporate NFT traits into NFT games, and much more. Furthermore, to help you answer the “what is NFT metadata?” question confidently, we’ll take a look at a metadata example in this article. As a result, you get to see some Moralis API endpoints in action.
Moreover, we encourage you to take these endpoints for a test ride yourself. To do so, create your free Moralis account and follow our lead! However, before we roll up our sleeves, let’s explain the ins and outs of metadata in NFT assets and NFT metadata storage.
Before answering “what is NFT metadata?”, let’s briefly look at NFTs and what they entail. NFTs are non-fungible crypto tokens, meaning that every NFT has a unique on-chain signature (token ID) and cannot be interchanged with other NFTs (unlike fungible tokens). This uniqueness makes NFTs perfect for representing unique digital or physical items. That said, it makes sense that digital art and digital collectibles are the most common NFT utility. However, NFTs have a huge potential beyond entertainment and speculative investing. By revolutionizing all sorts of certifications, membership/ownership proofing, online ticketing, and more, they can help create a more transparent and honest world.
On the other hand, metadata is, by definition, data about data. As such, metadata in NFT assets refers to specific pieces of information describing the NFT’s data. For instance, the above image points to different NFT traits categorized as the “attributes”. However, attributes are just one optional data type that can be stored in metadata for NFT assets. In fact, the exact metadata NFT includes varies depending on the NFT type. Though, there are several NFT standards set in place, such as ERC-721, ERC-1155, and SPL, which provide guidelines and rules. These rules define certain pieces of information that are essential in metadata and others that are optional. Hence, there is no exact format. However, an average metadata example includes a description, name, NFT-representing file destination (URL), and NFT attributes.
Behind every NFT or NFT collection, there is an NFT smart contract (as indicated in the above image). As you may know, smart contracts are pieces of on-chain software ensuring that predefined automated actions follow specific predefined rules when the right conditions are met. Accordingly, NFT smart contracts mint NFTs and regulate their transactions.
So, if you decide to mint your own NFTs, you need to write your own smart contract that follows the above-mentioned NFT standards and deploy it to the blockchain network of your choosing. Fortunately, there are verified NFT smart contract templates provided by open-source platforms, such as OpenZeppelin (EVM) or Metaplex (Solana). As such, you do not need to master Solidity or Rust to start minting NFTs in a decentralized manner. Of course, you do need to understand metadata storage. After all, providing a link to your metadata in a smart contract is vital. Hence, let’s focus on the metadata NFT storage aspect.
As seen in the above image, the data is stored, for example, on IPFS. Furthermore, just by looking at the above image, you immediately understand more than most NFT fanatics. You see, most users think that NFT-representing files are stored on the blockchain. However, that is not the case. After all, the NFT-representing files are too large, and keeping them on-chain would have catastrophic technical and economic consequences. Hence, NFT devs need to store those files elsewhere, ideally using a decentralized storage solution.
While metadata files are usually smaller than NFT-representing files, they would consume unnecessary valuable blockchain space. Thus, metadata NFT info is also not stored on the chain. Instead, NFT devs must store metadata files elsewhere and provide the link (URI) to the related NFT smart contract. Just like with NFT-representing files, devs have various storage options. Ideally, all devs should focus on using decentralized NFT metadata storage solutions. That said, before they can store the data properly, devs need to use a suitable format.
When it comes to the metadata format, you need to be aware of two factors. On the one hand, you need to know which NFT standard you are following to include the right pieces of information. On the other hand, you need to know what file format you will use. The latter will determine how to structure the details.
As you may know, there are several file formats used when it comes to metadata in general. However, the most common three alternatives are XML, TVS, and JSON file formats. Nonetheless, when it comes to metadata format, JSON is king. As such, let’s take a closer look at NFT JSON metadata.
In the image above, you can see an example NFT JSON metadata format. Moreover, the above example structure complies with the ERC-721 standard. As such, it includes the “name”, “description”, “image”, and “external_url” key-value pairs. Also, the “attributes” key contains “trait_type” and “value” sub-key, sub-value pairs. Furthermore, below is an actual NFT metadata example:
Nonetheless, the following are some of the main advantages that made the NFT JSON metadata format the norm in the crypto realm:
Now that you know that metadata NFT details typically come in the form of JSON files, it’s time to take a closer look at some popular storage solutions.
So, let’s say you have your NFT-representing files ready. By now, you know you need to link these files to your metadata NFT details. As such, before you actually create and store your NFT JSON metadata file, you need to store your NFT-representing files properly. As mentioned above, ideally, you’d choose a decentralized storage solution. Fortunately, there are some reliable solutions at your disposal. However, in our opinion, InterPlanetary File System (IPFS) stands out from the crowd. If you are hearing about this storage solution for the first time, make sure to read our “IPFS NFT” article. Moreover, the following are some other reputable decentralized storage solutions that deserve your consideration:
What’s next? Well, you can save your NFT-representing file to IPFS and obtain its URL (see the image displayed earlier). Then you can paste that URL into your NFT JSON metadata file alongside other details. Next, you can save that metadata file to IPFS as well and obtain its URI. Finally, to mint your NFT, you’ll need to paste that URI into your NFT smart contract that matches an NFT standard you’ve decided to focus on.
Of course, you can do all of that manually. However, thanks to Moralis’ IPFS integration, you can use the Moralis IPFS API to create and upload metadata or NFT-representing files using some simple lines of code. We’ll show you how to do that by uploading a metadata example.
We invite you to further solidify your metadata knowledge by completing the following example tutorial yourself. Fortunately, it only takes three simple steps to see the power of storing metadata in NFT to IPFS with Moralis. However, before you take on the upcoming steps, make sure you’ve completed the following prerequisites:
If you don’t have your Moralis account up and running yet, create it now. This will give you access to your admin area, where you’ll be able to obtain your Web3 API key:
To make things as straightforward for you as possible, you do not need to write the code yourself. Instead, you can simply copy-paste the following “index.js” example file:
Looking at the above lines of code, you can see the “uploadFolder” IPFS API endpoint. The latter does the heavy lifting of uploading metadata for NFT assets. Furthermore, you can also see our example “abi” constant, which includes all the metadata NFT details of our example NFT. Also, note that we’ve already uploaded our example NFT-representing SVG image. Actually, you can view it using a browser that supports IPFS addresses:
We covered quite a distance in today’s article. For starters, you had an opportunity to learn how to properly answer the “what is NFT metadata?” question. As such, you discovered what NFTs are and that their unique on-chain data make them valuable. We also explained how smart contracts fit into the NFT story. Next, you discovered that the metadata is not actually stored on the blockchain. Instead, it is typically stored inside NFT JSON metadata files. Then, we use storage solutions, such as IPFS, to host those files. Finally, you were able to follow our lead and create and upload an NFT metadata example.
If you are serious about NFT development, you have two options. You can explore further how to create your own NFTs. This will require dealing with smart contracts and also uploading NFT-representing files and metadata files to IPFS or other decentralized storage solutions. Of course, with the help of detailed instructions you can find on the Moralis blog, you’ll be able to do that without breaking a sweat.
Of course, you might also prefer to explore other blockchain development topics. Aside from our crypto blog, the Moralis YouTube channel will help you with that. After all, these two outlets cover a wide range of topics. For instance, some of the latest articles explain how AWS Lambda works, what Amazon GameSparks is, how to get NFT collection data, and much more.
Last but not least, you may also be eager to go full-time crypto as soon as possible. If so, you should enroll in Moralis Academy to become blockchain certified, and we recommend starting with blockchain and Bitcoin fundamentals.