📑ERC20 Details

Learn how to fetch ERC20 token details data, which includes name, symbol, logo images (original & resized), and total supply.

Airstack provides easy-to-use ERC20 token APIs for enriching Web3 applications with onchain and offchain ERC20 token data from Ethereum, Base, Degen Chain, and other Airstack-supported chains.

Table Of Contents

In this guide you will learn how to use Airstack to:

Pre-requisites

  • An Airstack account

  • Basic knowledge of GraphQL

Get Started

JavaScript/TypeScript/Python

If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:

React

npm install @airstack/airstack-react

Node

npm install @airstack/node

Then, add the following snippets to your code:

import { init, useQuery } from "@airstack/airstack-react";

init("YOUR_AIRSTACK_API_KEY");

const query = `YOUR_QUERY`; // Replace with GraphQL Query

const Component = () => {
  const { data, loading, error } = useQuery(query);

  if (data) {
    return <p>Data: {JSON.stringify(data)}</p>;
  }

  if (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }
};

Other Programming Languages

To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.

🤖 AI Natural Language​

Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.

Get ERC20 Token Total Supply

You can fetch an ERC20 token's total supply by using the totalSupply field from Tokens API by providing ERC20 token contract address as an input:

Try Code

Demo

query TotalSupply {
  Tokens(
    input: {
      filter: { address: { _eq: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" } }
      blockchain: ethereum
    }
  ) {
    Token {
      totalSupply
      decimals
    }
  }
}

Get ERC20 Token Name & Symbol

You can fetch an ERC20 token's name and symbol by using the name and symbol fields from Tokens API by providing ERC20 token contract address as an input:

Try Demo

Code

query MyQuery {
  Tokens(
    input: {
      filter: { address: { _eq: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" } }
      blockchain: ethereum
    }
  ) {
    Token {
      name
      symbol
    }
  }
}

Get ERC20 Token Logo Images

You can fetch all ERC20 token logo images by using the Tokens API by providing ERC20 token contract address as an input:

Try Demo

Code

query MyQuery {
  Tokens(
    input: {
      filter: { address: { _eq: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" } }
      blockchain: ethereum
    }
  ) {
    Token {
      projectDetails {
        imageUrl
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching ERC20 details data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?