With the enterprise-grade Token API from Moralis, you may get token metadata rapidly and simply. In actual fact, with the next code snippets using two completely different endpoints, you may get token metadata by image and contract deal with:
Get token metadata by image:const response = await Moralis.EvmApi.token.getTokenMetadataBySymbol({
symbols,
chain,
}); Get token metadata by contract deal with:const response = await Moralis.EvmApi.token.getTokenMetadata({
addresses,
chain,
});
For those who’re an skilled developer, odds are you already know tips on how to implement the code snippets above. If that’s the case, join a free Moralis account and begin utilizing the entire API’s functionalities instantly!
Nonetheless, should you’d wish to know tips on how to use the code above, learn on as we present you step-by-step tips on how to implement the snippets and get token metadata! Furthermore, earlier than shifting additional on this article, it’s essential to have an energetic Moralis account to finish the article’s tutorial. Thus, create your free Moralis account now!
Overview
As it’s possible you’ll know, there are several types of crypto tokens – fungible tokens (FTs), non-fungible tokens (NFTs), and semi-fungible tokens (SFTs). All these tokens play a variety of roles within the Web3 house. Moreover, there are numerous prospects in which you’ll construct dapps (decentralized purposes) incorporating these tokens. Furthermore, to make the most of any crypto token to the fullest, it’s essential to know tips on how to get token metadata. Thus, you must grasp the above-presented strategies. Nonetheless, whereas we’ll deal with fungible tokens (ERC-20) in at this time’s tutorial, Moralis additionally supplies you with the final word NFT API. The latter is the go-to instrument when constructing dapps that includes NFT performance, equivalent to getting all NFT transfers, NFT metadata, NFT assortment knowledge, and so forth. Even should you’ve been questioning tips on how to get all transfers of an NFT, that is the instrument you want.
It’s value declaring that each the Token API and NFT API are a part of the very best EVM API. Which means except for focusing on the Ethereum community, with this toolbox, you may effortlessly question all supported EVM-compatible chains.
Shifting ahead, we’ll first cowl the fundamentals of the “token metadata” matter. That is the place you’ll have a chance to be taught what token metadata is, what several types of token metadata there are, and what token metadata requirements entail. You’ll additionally be taught what makes Moralis the very best Web3 supplier to get token metadata. Lastly, we’ll invite you to tackle at this time’s tutorial to implement the above-presented snippets of code. Nonetheless, in case you already know the speculation behind tokens and their metadata, be at liberty to roll up your sleeves and leap straight to the “tutorial” part.

Exploring Token Metadata
With out understanding what token metadata is, it’s onerous to put it to use. As such, let’s first guarantee you may reply the “what’s token metadata?” query confidently. Token metadata refers to knowledge that focuses on what FTs, NFTs, or SFTs signify. Furthermore, since we’ll deal with FTs herein, let’s take a better have a look at fungible token metadata.
Chances are you’ll already know that crypto tokens are minted and ruled by good contracts. These items of on-chain software program outline automated actions that can happen when particular predefined conditioners are met. Moreover, the contracts mint FTs primarily based on particular particulars, which include obligatory and optionally available knowledge. In the case of ERC-20 contracts, the contract deal with and the full provide of tokens are the one two important particulars. Nonetheless, the token identify, image, and decimal numbers are the optimum items of data. These optionally available particulars signify fungible token metadata.
As well as, fungible tokens’ logos or thumbnails are additionally usually categorized as a part of metadata. Nonetheless, technically, FT metadata and an FT emblem are two separate issues. If nothing, you may retailer the previous on the blockchain, however you may’t with the latter. Nonetheless, whenever you use high-quality Web3 API endpoints to get token metadata, you’ll additionally get the tokens emblem (if accessible).

Completely different Varieties of Token Metadata
By now, you recognize that there are three major forms of tokens: FTs, NFTs, and SFTs. As such, there are additionally three several types of token metadata. Since we’ve already defined FT metadata above, we received’t go into additional particulars concerning these tokens. Furthermore, SFTs share the identical metadata frameworks as NFTs through the ERC-1155 (a.okay.a. ERC 1155) commonplace (extra on that under). As such, let’s have a look at NFT metadata extra carefully.
Not like FTs, non-fungible tokens include NFT-representing recordsdata, that are too massive to be saved on the blockchain. As an alternative, devs use token metadata to accommodate hyperlinks to those NFT recordsdata. Though these recordsdata are considerably smaller in measurement, it’s nonetheless not optimum each from a cost-effective and technical perspective to retailer NFT metadata recordsdata on the blockchain. Thus, each NFT metadata (sometimes JSON recordsdata) and NFT-representing recordsdata ought to ideally be saved utilizing a dependable decentralized storage answer (e.g., IPFS). Furthermore, except for different important particulars, solely the hyperlink to NFT metadata (URI) is saved on the blockchain.
Moreover, the main points included in NFT metadata fluctuate relying on the token commonplace. At least, token metadata features a identify and an emblem. Nonetheless, identical to with FTs, Moralis is the instrument to make use of when your purpose is to get token metadata by contract deal with for NFTs.

Token Metadata Requirements and What They Entail
Earlier than you be taught to get token metadata, it’s essential to understand that there are a lot of completely different token requirements for various programmable blockchains. As an illustration, SPL token commonplace governs FTs and NFTs on the Solana community. However, varied ERC requirements run the present on Ethereum and different EVM-compatible chains. Notably, ERC-20, ERC-721, and ERC-1155 are the three requirements protecting nearly all of tokens. What’s noteworthy is that each one older FTs and NFTs are ruled by ERC-20 and ERC-721. Nonetheless, because the delivery of ERC-1155, devs have tended to make use of this common commonplace for manufacturing functions. In spite of everything, this commonplace covers each FTs and NFTs. It additionally launched semi-fungible tokens. Nonetheless, for easy fungible tokens, ERC-20 is a greater match. Additionally, you’d most likely want to make use of ERC-721 for a easy NFT. But, should you’re excited by creating tokens with costly use instances, ERC-1155 is the go-to commonplace.
Observe: For extra particulars about this common commonplace, use the “ERC 1155” hyperlink above.
So, what particulars does this commonplace’s metadata embrace? Other than file title and sort, ERC-1155 token metadata comes with the next objects:
NameDecimalsDescriptionImage/FileProperties – Utilizing this optionally available object, token builders get so as to add distinctive properties, often known as NFT attributes/traits, with out affecting the top-level metadata construction.
Observe: If you wish to discover a generic ERC-1155 metadata JSON file, ensure that to learn our final information to token metadata.
The Finest Web3 Supplier to Get Token Metadata
For those who lined the above sections, you already know that Moralis is the very best instrument to get token metadata by contract deal with, image (FTs), or token ID (NFTs). You’ve additionally realized that that is doable due to the final word Token API and NFT API. Nonetheless, you will not be conscious that this final Web3 API supplier, Moralis, additionally presents the very best Web3 Auth API, Solana API, and Streams API. The latter lets you hearken to all main blockchain networks, together with the Sepolia testnet.
Moralis can also be all about cross-chain interoperability. This implies you get to make use of these advancing instruments with all main chains. Plus, this future-proofs your work as you’re by no means caught to any explicit chain.

Moreover, Moralis is totally cross-platform interoperable, which means you need to use your favourite programming language, framework, or dev platform to hitch the Web3 revolution. All in all, Moralis empowers you to construct dapps quicker and smarter with APIs that bridge the event hole between Web2 and Web3. Are you able to take this unbelievable instrument for a spin?

Tutorial: Easy methods to Get Token Metadata Utilizing NextJS and NodeJS
The aim of the sections above was to get you all up to the mark and able to deal with at this time’s tutorials. Each of the upcoming sub-tutorials comply with the identical ideas – they use NodeJS for the backend and NextJS for the frontend. In each situations, you’ll have a chance to construct a dapp that fetches token metadata. Nonetheless, we’ll first present you tips on how to get token metadata by image. However, the second tutorial will train you tips on how to get token metadata by contract deal with. So, the 2 dapps might be comparatively related, however they are going to deal with using two completely different endpoints.
The primary one makes use of the “get token metadata by image” endpoint, and the second makes use of the “get token metadata by deal with” endpoint. Each of the endpoints soak up one required parameter. Fairly intuitively, when looking tokens by symbols, “symbols” is the required parameter. However, when looking by deal with, “addresses” is the required parameter. Furthermore, the plural type of each required parameters signifies that these two endpoints really assist you to search by an array of strings.
Observe: Go to the Moralis docs to check the endpoints.
Nonetheless, if you wish to comply with our lead and create your individual occasion of both and even each of our instance dapps, it’s essential to have your Moralis account prepared. So, in case you haven’t completed so but, ensure that to create your account now. By doing so, you’ll be capable of entry your Moralis admin space and acquire your Web3 API key. Right here is the two-step course of to get that key:
For now, maintain on to your Web3 API key; we’ll level out the place you must paste it shifting ahead. So, with out additional ado, let’s dive into the primary tutorial and discover tips on how to get token metadata by image!
Get Token Metadata by Image
Earlier than you get your fingers soiled, we would like you to know precisely what you’ll be constructing. As such, let’s do a fast demo of our instance dapp that we ran on an area host. Within the screenshot under, you may see the title of our instance dapp on the high. Subsequent comes the “Add Image” entry subject, adopted by the “Choose Chain” drop-down menu. For the sake of this demonstration, allow us to deal with Chainlink (LINK). So, we enter this token’s ticker and choose the Ethereum chain:

To get the metadata, we have to click on on the “Submit” button:
Wanting on the above screenshot, you may see that our instance dapp shows a number of outcomes. Every consequence comprises the LINK token’s metadata for a special deal with. Furthermore, our dapp shows a emblem/thumbnail (if relevant) on the far left. Additionally, it shows the identify within the middle and the image on the far proper. Let’s additionally use our browser’s console to examine what’s happening behind the scenes:
After all, the leads to the console correspond to those that the “get token metadata by image” endpoint supplies. Now, this additionally concludes our demo. So, if you wish to construct your individual occasion of our instance dapp, use our “get-metadata-by-symbol” GitHub repo. There you will discover the entire frontend and backend code.
Backend Code Walkthrough
To make use of our code, ensure that to put in all of the required dependencies – “cors“, “dotenv“, “categorical“, and “moralis“. For those who open the “index.js” file from the “backend” folder, you’ll see how we used these dependencies on the high:

As you may see within the above screenshot, that is additionally the place we used port “5001” for our backend dapp. After all, you may comply with our lead or use some other port accessible in your pc. You can even see the road of code that processes our Moralis Web3 API key. This brings us to the half the place you lastly paste the above-obtained API key. As such, create and open the “.env” file and populate the “MORALIS_API_KEY” variable:
If we return to the “index.js” file, you may see the “/image” endpoint, which is the place we use the ability of Moralis to get token metadata by image:

Furthermore, we’re offering the “getTokenMetadataBySymbol” EVM API endpoint with its required parameter (“symbols“) and an optionally available one (“chain“). As demonstrated above, our backend dapp will question the values of each of those parameters from the frontend.
Final however not least, on the backside of our “index.js” backend file, we’re additionally firing up Moralis with the “begin” operate and listening to the port:
Frontend Code Walkthrough
Because you most likely have greater than sufficient expertise utilizing JavaScript (JS) for frontend purposes, we received’t be diving into that half herein. Nonetheless, it’s possible you’ll use the video under. Beginning at 5:07, you’ll be taught which dependencies it’s essential to set up to make use of our NextJS code. Then, you’ll have an opportunity to take a look at the script for our instance dapp’s homepage. That mentioned, crucial frontend script is “important.js“. Beginning at 5:30, you’ll have a chance to undergo it line by line.
Lastly, right here’s the video tutorial that can give you all the main points it’s essential to know to get token metadata by image:
Get Token Metadata by Contract Handle
Now that you recognize the ins and outs of our instance dapp to get token metadata by image, you’ll discover it tremendous straightforward to get token metadata by contract deal with. Moreover, the purpose of this a part of at this time’s article is so that you can construct your individual occasion of the “Get Metadata by Contract” dapp. Furthermore, you may see the gist of this dapp within the following screenshot:

Primarily, this dapp’s backend and frontend scripts are nearly precisely the identical as these of the dapp within the earlier part. As such, you will have two choices shifting ahead. On the one hand, you may merely tweak the code used within the above tutorial. Or, you may get the ultimate code from our “get-metadata-by-contract” GitHub repo web page. In spite of everything, relating to the backend code, the one distinction is within the endpoint we use. So, as a substitute of the “/image” endpoint, we create the “/contract” endpoint:

Wanting on the picture above, you may see that this endpoint takes within the “addresses” parameter as a substitute of “symbols”.
In case you skipped the earlier part, ensure that to look at the video under. The latter will stroll you thru the backend and frontend code it’s essential to implement to get token metadata by contract deal with.
Tutorial on Easy methods to Get Token Metadata Utilizing NextJS and NodeJS – Abstract
In at this time’s in depth article, you had an opportunity to go from understanding mainly nothing about token metadata to truly working with this sort of knowledge. You first realized the fundamentals of token metadata and the differing types and requirements. You additionally found which out of all accessible suppliers is the very best Web3 supplier to get token metadata by contract deal with and image. Nonetheless, you had a chance to tackle a easy tutorial and create your occasion of a neat dapp. Finally, you now know tips on how to get token metadata with out breaking a sweat or the financial institution.
For those who’re critical about dapp growth, ensure that to dive into the Moralis documentation and learn to take advantage of this highly effective Web3 API endpoint set. In spite of everything, there are tutorials within the docs for each API endpoint. However, don’t forget to develop your crypto horizons by visiting the Moralis YouTube channel and our blockchain growth weblog. Moreover, if you wish to enhance your probabilities of touchdown your dream job in Web3, you must think about enrolling in Moralis Academy. This offers you entry to many pro-grade programs; nevertheless, we advocate beginning with blockchain and Bitcoin fundamentals.