Skip to main content
Version: 2.2

How to get ERC20 metadata by symbols

Step 1: Setup Moralis

Read the article Setting Up Moralis: Getting Started and make sure to finish all the steps. Only after that you can go ahead to complete this guide.

Step 2: Get ERC20 metadata by symbols

In order to get ERC20 metadata by symbols, Moralis provides you with an getTokenMetadataBySymbol endpoint.

Here you'll need two parameters: symbols and chain.

Once you have obtained the symbols and chain, you can copy the following code:

const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");

const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});

const symbols = ["UNI", "AAVE", "LINK"];

const chain = EvmChain.ETHEREUM;

const response = await Moralis.EvmApi.token.getTokenMetadataBySymbol({
symbols,
chain,
});

console.log(response.toJSON());
};

runApp();

Step 3: Run the script

To run the script, enter the following command:

node index.js

In your terminal, you should see the following JSON response:

[
{
"address": "0x514910771af9ca656af840dff83e8264ecf986ca",
"name": "Chain Link",
"symbol": "LINK",
"decimals": "18",
"logo": "https://cdn.moralis.io/eth/0x514910771af9ca656af840dff83e8264ecf986ca.webp",
"logo_hash": "fd74ea1227adb458733847c09aab05d89c35c14b640c5ee1e0a8bffa79193eb4",
"thumbnail": "https://cdn.moralis.io/eth/0x514910771af9ca656af840dff83e8264ecf986ca_thumb.webp",
"block_number": null,
"validated": null,
"created_at": "2022-01-20T10:39:55.818Z"
},
{
"address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
"name": "Uniswap",
"symbol": "UNI",
"decimals": "18",
"logo": "https://cdn.moralis.io/eth/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.webp",
"logo_hash": "064ee9557deba73c1a31014a60f4c081284636b785373d4ccdd1b3440df11f43",
"thumbnail": "https://cdn.moralis.io/eth/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984_thumb.webp",
"block_number": null,
"validated": null,
"created_at": "2022-01-20T10:39:55.818Z"
},
{
"address": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
"name": "Aave Token",
"symbol": "AAVE",
"decimals": "18",
"logo": "https://cdn.moralis.io/eth/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.webp",
"logo_hash": "a43e5ac48a66d8b0eac410ac2f5634c2517acda6f4723a55b99e3c5906132a1b",
"thumbnail": "https://cdn.moralis.io/eth/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9_thumb.webp",
"block_number": null,
"validated": null,
"created_at": "2022-01-20T10:39:55.818Z"
}
]

Congratulations 🥳 You just got ERC20 metadata by symbols with just a few lines of code using the Moralis Token API!

Youtube Video

API Reference

If you want to know more details on the endpoint and optional parameters, check out:

Support

If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.