💸Token Transfers

Learn how to use Airstack to fetch all ERC20/721/1155 token transfers data, from or to user(s), across Ethereum, Base, Degen Chain, and other Airstack supported chains.

Airstack provides a TokenTransfers API for you to fetch all ERC20/721/1155 token transfer data from either a user or multiple users on 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.

Get Token Transfers Sent From A User

You can fetch all token transfers sent from a given user, e.g. betashop.eth, on Ethereum, Base, Degen Chain, and other Airstack-supported chains by using the TokenTransfers API:

For fetching token transfers data from multiple chains, check out Cross-Chain Queries.

Try Demo

Show me token transfers sent from betashop.eth on Ethereum

Code

query GetTokenTransfers {
  TokenTransfers(
    input: {
      filter: {
        # Only get token transfers from betashop.eth
        from: {_eq: "betashop.eth"},
        # Remove all minting/burning + self-transfer
        _nor: {
          from: {_in: ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dEaD"]},
          to: {_in: ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dEaD", "betashop.eth"]}
        }
      },
      blockchain: ethereum,
      limit: 50
    }
  ) {
    TokenTransfer {
      formattedAmount
      tokenType
      token {
        name
      }
    }
  }
}

Get Token Transfers Received By A User

You can fetch all token transfers received by a given user, e.g. betashop.eth, on Ethereum, Base, Degen Chain, and other Airstack-supported chains by using the TokenTransfers API:

For fetching token transfers data from multiple chains, check out Cross-Chain Queries.

Try Demo

Show me token transfers received by betashop.eth on Ethereum

Code

query GetTokenTransfers {
  TokenTransfers(
    input: {
      filter: {
        # Only get token transfers to betashop.eth
        to: {_eq: "betashop.eth"},
        # Remove all minting/burning + self-transfer
        _nor: {
          from: {_in: ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dEaD", "betashop.eth"]},
          to: {_in: ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dEaD"]}
        }
      },
      blockchain: ethereum,
      limit: 50
    }
  ) {
    TokenTransfer {
      formattedAmount
      tokenType
      token {
        name
      }
    }
  }
}

Get The Most Recent Token Transfers Sent From A User(s)

You can fetch all most recent token transfers sent from a given user, e.g. betashop.eth, across multiple chains, such as Ethereum, Base, Degen Chain, and other Airstack-supported chains, by using the TokenTransfers API:

For fetching most recent token transfers data from multiple chains, check out Cross-Chain Queries.

Try Demo

Show me the most recent token transfers sent from betashop.eth on Ethereum

Code

query GetTokenTransfers {
  TokenTransfers(
    input: {
      filter: {
        # Only get token transfers from betashop.eth
        from: { _eq: "betashop.eth" }
      }
      blockchain: ethereum
      limit: 50
      order: { blockTimestamp: DESC } # Order transfers by blocktimestamp in descending order
    }
  ) {
    TokenTransfer {
      formattedAmount
      tokenType
      token {
        name
      }
    }
  }
}

Get The Most Recent Token Transfers Received By A User

You can fetch most recent token transfers received by a given user, e.g. betashop.eth, across multiple chains, such as Ethereum, Base, Degen Chain, and other Airstack-supported chains, by using the TokenTransfers API:

For fetching most recent token transfers data from multiple chains, check out Cross-Chain Queries.

Try Demo

Show me the most recent token transfers received by betashop.eth on Ethereum

Code

query GetTokenTransfers {
  TokenTransfers(
    input: {
      filter: {
        # Only get token transfers to betashop.eth
        to: {_eq: "betashop.eth"},
      },
      blockchain: ethereum,
      limit: 50,
      order: { blockTimestamp: DESC } # Order transfers by blocktimestamp in descending order
    }
  ) {
    TokenTransfer {
      formattedAmount
      tokenType
      token {
        name
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching token transfers data into your application, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?