Skip to main content

How to get erc20 token metadata by symbol

Prerequisites

Before getting started, make sure you have the following ready:

  • Node v.14+
  • NPM

Step 1: Setup Blocklens

First register your Blocklens account and get your Blocklens API Key.

Once you have your Blocklens API Key, install the Blocklens SDK in your project.

npm i blocklens-sdk

Step 2: Get ERC20 token metadata by symbol

In order to get erc20 token metadata by symbol, Blocklens provides you a getErc20MetadataBySymbol endpoint to do so.

Here you'll need a parameter: symbol.

Once you've obtained the symbol, you can copy the following code:

import Blocklens from "blocklens-sdk";

const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });

const runApis = async () => {
const response = await blocklens.ETH_MAINNET.getErc20MetadataBySymbol("FEELS");
console.log(response);
};

runApis();

Step 3: Run the script

ts-node index.ts

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

{
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjB4MDMyMzZFREY0NTQxZTczYTFFYzgyMjg2OTc5NDhlODg5NTk0MDA2NyIsInBhZ2UiOjEsInN5bWJvbCI6IkZFRUxTIiwiaWF0IjoxNjk3MDYzNDY1fQ.r8jHYguCSqgogj3ikGPHo4JqCHnPnnn9otucdOXIcvE",
"page": 1,
"limit": 20,
"total_items": 1,
"data": [
{
"name": "FEELS GOOD MAN",
"symbol": "FEELS",
"decimals": 18,
"contract_address": "0x03236EDF4541e73a1Ec8228697948e8895940067",
"total_supply": "50000000000000000000000000000",
"description": null,
"icon_url": null,
"last_synced_at": 1696021312
}
]
}

Congratulations 🥳 you just found the get erc20 token metadata by symbol on multiple chains with only a few lines of code using the Blocklens Wallet API!

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.