With the enterprise-grade Token API from Moralis, you will get token metadata rapidly and simply. Actually, with the next code snippets using two totally different endpoints, you will get token metadata by image and contract handle:
Get token metadata by image:const response = await Moralis.EvmApi.token.getTokenMetadataBySymbol({
symbols,
chain,
}); Get token metadata by contract handle:const response = await Moralis.EvmApi.token.getTokenMetadata({
addresses,
chain,
});
In case you’re an skilled developer, odds are you already know the right way to implement the code snippets above. In that case, join a free Moralis account and begin utilizing the entire API’s functionalities instantly!
Nevertheless, for those who’d wish to know the right way to use the code above, learn on as we present you step-by-step the right way to implement the snippets and get token metadata! Furthermore, earlier than shifting additional on this article, it’s worthwhile to have an energetic Moralis account to finish the article’s tutorial. Thus, create your free Moralis account now!
Overview
As you might know, there are various kinds 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 area. Moreover, there are numerous potentialities 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 worthwhile to know the right way to get token metadata. Thus, it is best to grasp the above-presented strategies. Nonetheless, whereas we’ll concentrate on fungible tokens (ERC-20) in in the present day’s tutorial, Moralis additionally offers you with the last 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 information, and so forth. Even for those who’ve been questioning the right way to get all transfers of an NFT, that is the instrument you want.
It’s price declaring that each the Token API and NFT API are a part of one of the best EVM API. Which means that apart from focusing on the Ethereum community, with this toolbox, you possibly can effortlessly question all supported EVM-compatible chains.
Shifting ahead, we’ll first cowl the fundamentals of the “token metadata” subject. That is the place you’ll have a possibility to study what token metadata is, what various kinds of token metadata there are, and what token metadata requirements entail. You’ll additionally study what makes Moralis one of the best Web3 supplier to get token metadata. Lastly, we’ll invite you to tackle in the present day’s tutorial to implement the above-presented snippets of code. Nevertheless, in case you already know the idea behind tokens and their metadata, be at liberty to roll up your sleeves and bounce straight to the “tutorial” part.

Exploring Token Metadata
With out understanding what token metadata is, it’s arduous to put it to use. As such, let’s first guarantee you possibly can reply the “what’s token metadata?” query confidently. Token metadata refers to information that focuses on what FTs, NFTs, or SFTs symbolize. Furthermore, since we’ll concentrate on FTs herein, let’s take a more in-depth take a look at fungible token metadata.
You might 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 based mostly on particular particulars, which encompass necessary and optionally available information. In the case of ERC-20 contracts, the contract handle and the entire provide of tokens are the one two important particulars. Nevertheless, the token title, image, and decimal numbers are the optimum items of data. These optionally available particulars symbolize fungible token metadata.
As well as, fungible tokens’ logos or thumbnails are additionally usually categorized as a part of metadata. Nevertheless, technically, FT metadata and an FT emblem are two separate issues. If nothing, you possibly can retailer the previous on the blockchain, however you possibly can’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 Forms of Token Metadata
By now, that there are three major forms of tokens: FTs, NFTs, and SFTs. As such, there are additionally three various kinds of token metadata. Since we’ve already defined FT metadata above, we gained’t go into additional particulars concerning these tokens. Furthermore, SFTs share the identical metadata frameworks as NFTs by way of the ERC-1155 (a.ok.a. ERC 1155) normal (extra on that beneath). As such, let’s take a look at NFT metadata extra carefully.
In contrast to FTs, non-fungible tokens include NFT-representing information, that are too massive to be saved on the blockchain. As a substitute, devs use token metadata to accommodate hyperlinks to those NFT information. Though these information are considerably smaller in dimension, it’s nonetheless not optimum each from a cheap and technical perspective to retailer NFT metadata information on the blockchain. Thus, each NFT metadata (usually JSON information) and NFT-representing information ought to ideally be saved utilizing a dependable decentralized storage resolution (e.g., IPFS). Furthermore, apart from different important particulars, solely the hyperlink to NFT metadata (URI) is saved on the blockchain.
Moreover, the small print included in NFT metadata fluctuate relying on the token normal. At least, token metadata features a title and a logo. Nonetheless, identical to with FTs, Moralis is the instrument to make use of when your aim is to get token metadata by contract handle for NFTs.

Token Metadata Requirements and What They Entail
Earlier than you study to get token metadata, it’s worthwhile to take into account that there are a lot of totally different token requirements for various programmable blockchains. As an illustration, SPL token normal governs FTs and NFTs on the Solana community. Alternatively, numerous ERC requirements run the present on Ethereum and different EVM-compatible chains. Significantly, ERC-20, ERC-721, and ERC-1155 are the three requirements overlaying nearly all of tokens. What’s noteworthy is that every one older FTs and NFTs are ruled by ERC-20 and ERC-721. Nevertheless, because the delivery of ERC-1155, devs have tended to make use of this common normal for manufacturing functions. In any case, this normal 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 desire to make use of ERC-721 for a easy NFT. But, for those who’re excited about creating tokens with costly use circumstances, ERC-1155 is the go-to normal.
Be aware: For extra particulars about this common normal, use the “ERC 1155” hyperlink above.
So, what particulars does this normal’s metadata embrace? Apart from file title and kind, 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.
Be aware: If you wish to discover a generic ERC-1155 metadata JSON file, be certain to learn our final information to token metadata.
The Finest Web3 Supplier to Get Token Metadata
In case you lined the above sections, you already know that Moralis is one of the best instrument to get token metadata by contract handle, image (FTs), or token ID (NFTs). You’ve additionally realized that that is potential due to the last word Token API and NFT API. Nevertheless, you might not be conscious that this final Web3 API supplier, Moralis, additionally affords one of the best Web3 Auth API, Solana API, and Streams API. The latter allows you to 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 might be by no means caught to any specific chain.

Moreover, Moralis is absolutely cross-platform interoperable, which means you should utilize your favourite programming language, framework, or dev platform to hitch the Web3 revolution. All in all, Moralis empowers you to construct dapps sooner 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: How you can Get Token Metadata Utilizing NextJS and NodeJS
The aim of the sections above was to get you all on top of things and able to deal with in the present day’s tutorials. Each of the upcoming sub-tutorials observe the identical ideas – they use NodeJS for the backend and NextJS for the frontend. In each cases, you’ll have a possibility to construct a dapp that fetches token metadata. Nevertheless, we’ll first present you the right way to get token metadata by image. Alternatively, the second tutorial will train you the right way to get token metadata by contract handle. So, the 2 dapps can be comparatively comparable, however they may concentrate on using two totally 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 handle” endpoint. Each of the endpoints absorb one required parameter. Fairly intuitively, when looking out tokens by symbols, “symbols” is the required parameter. Alternatively, when looking out by handle, “addresses” is the required parameter. Furthermore, the plural type of each required parameters signifies that these two endpoints really will let you search by an array of strings.
Be aware: Go to the Moralis docs to check the endpoints.
Nonetheless, if you wish to observe our lead and create your personal occasion of both and even each of our instance dapps, it’s worthwhile to have your Moralis account prepared. So, in case you haven’t accomplished so but, be certain to create your account now. By doing so, you’ll have the ability to 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 it is best to paste it shifting ahead. So, with out additional ado, let’s dive into the primary tutorial and discover the right way to get token metadata by image!
Get Token Metadata by Image
Earlier than you get your palms soiled, we wish 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 beneath, you possibly can see the title of our instance dapp on the high. Subsequent comes the “Add Image” entry discipline, adopted by the “Choose Chain” drop-down menu. For the sake of this demonstration, allow us to concentrate on 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:
Trying on the above screenshot, you possibly can see that our instance dapp shows a number of outcomes. Every outcome accommodates the LINK token’s metadata for a special handle. Furthermore, our dapp shows a emblem/thumbnail (if relevant) on the far left. Additionally, it shows the title within the heart and the image on the far proper. Let’s additionally use our browser’s console to examine what’s occurring behind the scenes:
In fact, the leads to the console correspond to those that the “get token metadata by image” endpoint offers. Now, this additionally concludes our demo. So, if you wish to construct your personal occasion of our instance dapp, use our “get-metadata-by-symbol” GitHub repo. There you will discover the whole frontend and backend code.
Backend Code Walkthrough
To make use of our code, be certain to put in all of the required dependencies – “cors“, “dotenv“, “categorical“, and “moralis“. In case you open the “index.js” file from the “backend” folder, you’ll see how we used these dependencies on the high:

As you possibly can see within the above screenshot, that is additionally the place we used port “5001” for our backend dapp. In fact, you possibly can observe 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 possibly can 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 gained’t be diving into that half herein. Nevertheless, you might use the video beneath. Beginning at 5:07, you’ll study which dependencies it’s worthwhile 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 stated, crucial frontend script is “principal.js“. Beginning at 5:30, you’ll have a possibility to undergo it line by line.
Lastly, right here’s the video tutorial that can give you all the small print it’s worthwhile to know to get token metadata by image:
Get Token Metadata by Contract Handle
Now that 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 handle. Moreover, the aim of this a part of in the present day’s article is so that you can construct your personal occasion of the “Get Metadata by Contract” dapp. Furthermore, you possibly can see the gist of this dapp within the following screenshot:

Primarily, this dapp’s backend and frontend scripts are virtually precisely the identical as these of the dapp within the earlier part. As such, you could have two choices shifting ahead. On the one hand, you possibly can merely tweak the code used within the above tutorial. Or, you will get the ultimate code from our “get-metadata-by-contract” GitHub repo web page. In any case, in terms of 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:

Trying on the picture above, you possibly can see that this endpoint takes within the “addresses” parameter as a substitute of “symbols”.
In case you skipped the earlier part, be certain to look at the video beneath. The latter will stroll you thru the backend and frontend code it’s worthwhile to implement to get token metadata by contract handle.
Tutorial on How you can Get Token Metadata Utilizing NextJS and NodeJS – Abstract
In in the present day’s intensive article, you had an opportunity to go from understanding principally nothing about token metadata to truly working with this sort of information. You first realized the fundamentals of token metadata and the different sorts and requirements. You additionally found which out of all accessible suppliers is one of the best Web3 supplier to get token metadata by contract handle and image. Nonetheless, you had a possibility to tackle a easy tutorial and create your occasion of a neat dapp. In the end, you now know the right way to get token metadata with out breaking a sweat or the financial institution.
In case you’re severe about dapp improvement, be certain to dive into the Moralis documentation and discover ways to profit from this highly effective Web3 API endpoint set. In any case, there are tutorials within the docs for each API endpoint. Alternatively, don’t forget to develop your crypto horizons by visiting the Moralis YouTube channel and our blockchain improvement weblog. Moreover, if you wish to enhance your possibilities of touchdown your dream job in Web3, it is best to take into account enrolling in Moralis Academy. This provides you with entry to many pro-grade programs; nonetheless, we advocate beginning with blockchain and Bitcoin fundamentals.