In the web application I am working on , I need to find the current price of an ERC20 token listed on etherscan . How can this be done using code or some etherscan api ? Any help is appreciated.

  • Please mark my ans as solved. If its resolved your problem. Feb 12, 2018 at 10:39
  • Will do..give me some time
    – Webdev
    Feb 12, 2018 at 10:44

4 Answers 4


To be honest it depends on exchanges. Different exchanges will have different trade value and It depending on demand. Unfortunately there is no common value for token. Usually there will be 1-5 some times 15% price different because it depending on country/exchange/local law/exchange commission etc..,

Yes there will be api is available. Refer below link's




You can Moralis API to get the pricing of tokens on Etherscan that exists on Ethereum blockchain. As long as they are listed in one of the DEX that Moralis support on Ethereum, you should be able to get the price of the ERC20 token.

First, you'll need to install the Moralis SDK:

npm install moralis

Then, sign up to https://admin.moralis.io to get your API key and add the following code to fetch the price:

import Moralis from 'moralis';

try {
  await Moralis.start({
    apiKey: "YOUR_API_KEY"

  const response = await Moralis.EvmApi.token.getTokenPrice({
    "chain": "0x1",
    "address": "YOUR_TOKEN_ADDRESS"

} catch (e) {

Once completed, you should be able to get the token prices. Moralis also offers here getMultipleTokenPrices API in case you need to fetch multiple token's prices.

Hope this helps!

P.S. I work at Moralis


For ERC-20 tokens, I assume you are looking for example how to find the market price of Basic Attention Token (BAT), an ERC-20 token deployed on Ethereum.

My suggestion is to try the Crypto API from CoinGecko

Reason being that, token names/symbols are tricky. There can be many "BAT" symbol tokens and say you don't want the hassle of maintaining a mapping of ids.

The CoinGecko API allows you to query token using contract address which is unique to a given token

Knowing the contract address for Basic Attention Token 0x0d8775f648430679a709e98d2b0cb6250d2887ef

You can query it with https://api.coingecko.com/api/v3/coins/ethereum/contract/0x0d8775f648430679a709e98d2b0cb6250d2887ef

As long as you know the ERC-20 contract address, you can query almost any market data so long its supported on CoinGecko in which it is quite likely the case.

  • The problem is coingecko doesn t supports as much tokens as Etherscan. Jun 5, 2022 at 2:04

You can also use chainbase free api to fetch current price of erc20 token.

API : https://docs.chainbase.com/reference/gettokenprice

suggest code

network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.
token_addr = '0xdAC17F958D2ee523a2206206994597C13D831ec7'; // Take USDT as an example.

    fetch(`https://api.chainbase.online/v1/token/price?chain_id=${network_id}&contract_address=${token_addr}`, {
        method: 'GET',
        headers: {
            'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key.
            'accept': 'application/json'
    }).then(response => response.json())
        .then(data => console.log(data.data))
        .catch(error => console.error(error));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.