πŸ‘›NFT Mints

Learn how to use Airstack to fetch all NFT mints data, from or to user(s), across Ethereum, Base, Degen Chain, and other Airstack-supported chains.

All tokens minted are essentially NFT transfers from a null address (0x00...00) to a user address that are executed by the receiving user itself. Thus, with Airstack, you can use the TokenTransfers API to fetch all user's token mints by specifying the input as follows:

Input FilterValueDescription

operator

user's 0x address, ENS, cb.id, Lens, or Farcaster

Executor of the transaction.

from

Sender in the ERC721/1155 token transfers.

to

user's 0x address, ENS, cb.id, Lens, or Farcaster

Receiver in the ERC721/1155 token transfers.

Table Of Contents

In this guide you will learn how to use Airstack to get NFT mints by a user.

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 NFT Mints By A User

You can fetch all NFTs minted by a user, e.g. betashop.eth, across multiple chains, such as Ethereum, Base, Degen Chain, and other Airstack-supported chains, by using the TokenTransfers API:

Try Demo

Code

query MyQuery {
  Ethereum: TokenTransfers(
    input: {
      filter: {
        # Only get mints that are executed by the same user
        operator: {_eq: "betashop.eth"},
        # Mints are token transfers that has null address as `from`
        from: {_eq: "0x0000000000000000000000000000000000000000"},
        # Set this to the user that receive the token mints
        to: {_eq: "betashop.eth"},
        # Get only NFTs (ERC721/1155)
        tokenType: {_in: [ERC721, ERC1155]},
      },
      blockchain: ethereum,
      order: {blockTimestamp: DESC}
    }
  ) {
    TokenTransfer {
      blockchain
      formattedAmount
      tokenAddress
      tokenId
      tokenNft {
        metaData {
          name
        }
        contentValue {
          image {
            medium
          }
        }
      }
      tokenType
    }
  }
  Base: TokenTransfers(
    input: {
      filter: {
        # Only get mints that are executed by the same user
        operator: {_eq: "betashop.eth"},
        # Mints are token transfers that has null address as `from`
        from: {_eq: "0x0000000000000000000000000000000000000000"},
        # Set this to the user that receive the token mints
        to: {_eq: "betashop.eth"},
        # Get only NFTs (ERC721/1155)
        tokenType: {_in: [ERC721, ERC1155]},
      },
      blockchain: base,
      order: {blockTimestamp: DESC}
    }
  ) {
    TokenTransfer {
      blockchain
      formattedAmount
      tokenAddress
      tokenId
      tokenNft {
        metaData {
          name
        }
        contentValue {
          image {
            medium
          }
        }
      }
      tokenType
    }
  }
}

Developer Support

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

More Resources

Last updated