Links
👛

Token Mints

Learn how to use Airstack to fetch all ERC20/721/1155 token mints data, from or to user(s), across Ethereum, Polygon, Base, and Zora.
All tokens minted are essentially token 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 Filter
Value
Description
operator
user's 0x address, ENS, cb.id, Lens, or Farcaster
Executor of the transaction.
from
0x0000000000000000000000000000000000000000
Sender in the ERC20/721/1155 token transfers.
to
user's 0x address, ENS, cb.id, Lens, or Farcaster
Receiver in the ERC20/721/1155 token transfers.
You also have the option to add blockTimestamp filter to your query to fetch all tokens that are minted during a specified period of time:
Input Filter
Value
Description
blockTimestamp
Specific time period to fetch token mints, use _gt or _gte and _lt or _lte filters to specify the timestamp period. Look at example below for NFT and ERC20 mints.
Allows entering blockTimestamp to filter transactions which happened in specific periods. Time format should be following the unix timstamp format, e.g. 2023-01-01T00:00:00Z

Table Of Contents

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

Pre-requisites

  • An Airstack account (free)
  • Basic knowledge of GraphQL

Get Started

JavaScript/TypeScript/Python

If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm
yarn
pnpm
pip
React
npm install @airstack/airstack-react
Node
npm install @airstack/node
React
yarn add @airstack/airstack-react
Node
yarn add @airstack/node
React
pnpm install @airstack/airstack-react
Node
pnpm install @airstack/node
pip install airstack
Then, add the following snippets to your code:
React
Node
Python
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>;
}
};
import { init, fetchQuery } from "@airstack/node";
init("YOUR_AIRSTACK_API_KEY");
const query = `YOUR_QUERY`; // Replace with GraphQL Query
const { data, error } = await fetchQuery(query);
console.log("data:", data);
console.log("error:", error);
import asyncio
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key="YOUR_AIRSTACK_API_KEY")
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main():
execute_query_client = api_client.create_execute_query_object(
query=query)
query_response = await execute_query_client.execute_query()
print(query_response.data)
asyncio.run(main())

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.
Airstack AI (Demo)

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, Polygon, Base, and Zora, by using the TokenTransfers API:

Try Demo

https://app.airstack.xyz/query/HiNkAcW8C7
Show me all NFTs minted by betashop.eth

Code

Query
Response
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
}
}
Polygon: 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: polygon,
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
}
}
Zora: 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: zora,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
tokenAddress
tokenId
tokenNft {
metaData {
name
}
contentValue {
image {
medium
}
}
}
tokenType
}
}
}
{
"data": {
"Ethereum": {
"TokenTransfer": [
{
"blockchain": "ethereum",
"formattedAmount": 1,
"tokenAddress": "0x0f92612c5f539c89dc379e8aa42e3ba862a34b7e",
"tokenId": "8",
"tokenNft": {
"metaData": {
"name": "Venture Club Alpha Membership NFT"
},
"contentValue": {
"image": {
"medium": "https://assets.uat.airstack.xyz/image/nft/li5d4XIGDPxtahI+EMjNmOiSymdFmCR0OsRC2p13nDaZQijmEYVpYlbV0t57GD8K/medium.jpg"
}
}
},
"tokenType": "ERC721"
}
// Other NFTs minted by betashop.eth on Ethereum
]
},
"Polygon": {
"TokenTransfer": [
{
"blockchain": "polygon",
"formattedAmount": 1,
"tokenAddress": "0x0ff0095b74eca3644e62f91dbe952faf677efc12",
"tokenId": "26723",
"tokenNft": {
"metaData": {
"name": "ctrlaltf.lens's follower NFT"
},
"contentValue": {
"image": {
"medium": "https://assets.uat.airstack.xyz/image/nft/Ycq8Xr2vFpq0mTH7PnGk+oX4ZZDmBg9VWLv5LariQ3qQGuLBLG98xy7DN6D1F7lnfaKEpaNPsLerS7eamSbl6w==/medium.svg"
}
}
},
"tokenType": "ERC721"
}
// Other NFTs minted by betashop.eth on Polygon
]
},
"Base": {
"TokenTransfer": [
{
"blockchain": "base",
"formattedAmount": 1,
"tokenAddress": "0xba5e05cb26b78eda3a2f8e3b3814726305dcac83",
"tokenId": "118",
"tokenNft": {
"metaData": {
"name": null
},
"contentValue": {
"image": null
}
},
"tokenType": "ERC1155"
}
]
},
"Zora": {
"TokenTransfer": null // No NFT mints by betashop.eth on Zora
}
}
}

Get ERC20 Token Mints By A User

You can fetch all ERC20 tokens minted by a user, e.g. ipeciura.eth, across multiple chains, such as Ethereum, Polygon, Base, and Zora, by using the TokenTransfers API:

Try Demo

https://app.airstack.xyz/query/RsCkWHyHjV
Show me all ERC20 tokens minted by ipeciura.eth

Code

Query
Response
query MyQuery {
Ethereum: TokenTransfers(
input: {
filter: {
# Only get mints that are executed by the same user
operator: {_eq: "ipeciura.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: "ipeciura.eth"},
# Get only ERC20 tokens
tokenType: {_eq: ERC20},
},
blockchain: ethereum,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
tokenAddress
token {
name
}
}
}
Polygon: 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: "ipeciura.eth"},
# Get only ERC20 tokens
tokenType: {_eq: ERC20},
},
blockchain: polygon,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
tokenAddress
token {
name
}
}
}
Base: TokenTransfers(
input: {
filter: {
# Only get mints that are executed by the same user
operator: {_eq: "ipeciura.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: "ipeciura.eth"},
# Get only ERC20 tokens
tokenType: {_eq: ERC20},
},
blockchain: base,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
tokenAddress
token {
name
}
}
}
Zora: TokenTransfers(
input: {
filter: {
# Only get mints that are executed by the same user
operator: {_eq: "ipeciura.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: "ipeciura.eth"},
# Get only ERC20 tokens
tokenType: {_eq: ERC20},
},
blockchain: zora,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
tokenAddress
token {
name
}
}
}
}
{
"data": {
"Ethereum": {
"TokenTransfer": null // No ERC20 token minted on Ethereum
},
"Polygon": {
"TokenTransfer": [
{
"blockchain": "polygon",
"formattedAmount": 0.01697896348647009,
"tokenAddress": "0xadbf1854e5883eb8aa7baf50705338739e558e5b",
"token": {
"name": "Uniswap V2"
}
},
// Other ERC20 tokens minted by ipeciura.eth on Polygon
]
},
"Base": {
"TokenTransfer": null // No ERC20 token minted on Base
},
"Zora": {
"TokenTransfer": null // No ERC20 token minted on Zora
}
}
}

Get NFT Mints By A User in a Specified Period

You can fetch all NFTs minted during a specified period of time by a user, e.g. ipeciura.eth, across different chains, e.g. Ethereum, Polygon, Base, and Zora, by using the TokenTransfers API:

Try Demo

https://app.airstack.xyz/query/1NeCdgZKG8
Show me ERC721/1155 Polygon NFT mints by ipeciura.eth in 2023

Code

Query
Response
query MyQuery {
TokenTransfers(
input: {
filter: {
# Only get mints that are executed by the same user
operator: {_eq: "ipeciura.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: "ipeciura.eth"},
# Get only ERC721/1155 NFTs
tokenType: {_in: [ERC721, ERC1155]},
# Specify time stamp (in 2023)
blockTimestamp: {
_gt: "2023-01-01T00:00:00Z", # (greater than - after Jan 1, 2023)
_lt: "2024-01-01T00:00:00Z" # (less than - before Jan 1, 2024)
}
},
blockchain: polygon,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
blockTimestamp
tokenAddress
tokenNft {
metaData {
name
}
contentValue {
image {
medium
}
}
}
tokenType
}
}
}
{
"data": {
"TokenTransfers": {
"TokenTransfer": [
{
"blockchain": "polygon",
"formattedAmount": 1,
"blockTimestamp": "2023-11-09T13:26:53Z",
"tokenAddress": "0xd3b4de0d85c44c57993b3b18d42b00de81809eea",
"tokenNft": {
"metaData": {
"name": "Unveiling Airstack's Onchain Graph #1"
},
"contentValue": {
"image": {
"medium": "https://assets.airstack.xyz/image/nft/N3xsCM4U2UsyVojt4p4OUOsbwHHkyl1MPU9iEHe4mr0FqR+Vy4cMTaTFc03m2rVApXUy38ASkynABWL/M3lLaQ==/medium.jpg"
}
}
},
"tokenType": "ERC721"
}
]
}
}
}

Get ERC20 Token Mints By A User in a Specified Period

You can fetch all ERC20 tokens minted during a specified period of time by a user, e.g. ipeciura.eth, across different chains, e.g. Ethereum, Polygon, Base, and Zora, by using the TokenTransfers API:

Try Demo

https://app.airstack.xyz/query/kQk6CRK9aT
Show me all Polygon ERC20 token mints by ipeciura.eth in 2022

Code

Query
Response
query MyQuery {
TokenTransfers(
input: {
filter: {
# Only get mints that are executed by the same user
operator: {_eq: "ipeciura.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: "ipeciura.eth"},
# Get only ERC20 tokens
tokenType: {_eq: ERC20}
# Specify time stamp (in 2022)
blockTimestamp: {
_gt: "2022-01-01T00:00:00Z", # (greater than - before Jan 1, 2022)
_lt: "2023-01-01T00:00:00Z" # (less than - before Jan 1, 2023)
}
},
blockchain: polygon,
order: {blockTimestamp: DESC}
}
) {
TokenTransfer {
blockchain
formattedAmount
blockTimestamp
tokenAddress
token {
name
}
}
}
}
{
"data": {
"TokenTransfers": {
"TokenTransfer": [
{
"blockchain": "polygon",
"formattedAmount": 0.01697896348647009,
"blockTimestamp": "2022-07-15T15:37:02Z",
"tokenAddress": "0xadbf1854e5883eb8aa7baf50705338739e558e5b",
"token": {
"name": "Uniswap V2"
}
},
{
"blockchain": "polygon",
"formattedAmount": 0.9908239030713007,
"blockTimestamp": "2022-07-15T14:45:54Z",
"tokenAddress": "0x9928340f9e1aaad7df1d95e27bd9a5c715202a56",
"token": {
"name": "Balancer B-stMATIC-STABLE RewardGauge Deposit"
}
}
// Other ERC20 tokens minted by ipeciura.eth on Polygon in 2022
]
}
}
}

Get Current Balance of Minted NFTs

Fetching

You can fetch the current NFT balances of minted NFTs, e.g. ipeciura.eth, across different chains, e.g. Ethereum, Polygon, Base, and Zora, by using the TokenTransfers API:

Try Demo

https://app.airstack.xyz/query/4dJEQDYR1K
Show current NFT balances of Minted NFTs on Polygon by ipeciura.eth

Code

Query
Response
query MyQuery {
TokenTransfers(
input: {
filter: {
# Only get mints that are executed by the same user
operator: {_eq: "ipeciura.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: "ipeciura.eth"},
# Get only ERC721/1155 NFTs
tokenType: {_in: [ERC1155, ERC721]}
},
order: {blockTimestamp: DESC},
blockchain: polygon
}
) {
TokenTransfer {
blockTimestamp
type
transactionHash
tokenNft {
contentValue {
image {
medium
}
}
}
token {
name
address
type
tokenBalances(input: {filter: {owner: {_eq: "ipeciura.eth"}}}) {
formattedAmount
}
}
}
}
}
{
"data": {
"TokenTransfers": {
"TokenTransfer": [
{
"blockTimestamp": "2023-11-09T13:26:53Z",
"type": "MINT",
"transactionHash": "0x633ce3c1c2050b2477d9b8e3ee4a8de41bfb15a2b8adc3f59cc7ba002a782b2f",
"tokenNft": {
"contentValue": {
"image": {
"medium": "https://assets.airstack.xyz/image/nft/N3xsCM4U2UsyVojt4p4OUOsbwHHkyl1MPU9iEHe4mr0FqR+Vy4cMTaTFc03m2rVApXUy38ASkynABWL/M3lLaQ==/medium.jpg"
}
}
},
"token": {
"name": "Unveiling Airstack's Onchain Graph",
"address": "0xd3b4de0d85c44c57993b3b18d42b00de81809eea",
"type": "ERC721",
"tokenBalances": [
{
"formattedAmount": 1 // Shows that ipeciura.eth current balance for this NFT
}
]
}
},
// Other minted NFTs by ipeciura.eth on Polygon
]
}
}
}

Formatting

To get the list of minted NFTs and their current balance in a flat array, use the following format function:
TypeScript
JavaScript
Python
interface Token {
name: string;
type: string;
address: string;
tokenBalances: { formattedAmount?: string }[];
}
interface TokenTransfer {
token: Token;
}
interface Data {
TokenTransfers?: {
TokenTransfer: TokenTransfer[];
};
}
/**
* @description Formats the NFT mints data.
*
* @example
* import { fetchQuery } from "@airstack/node";
*
* const { data } = await fetchQuery(query, variables);
* const res = formatFunction(data);
*
* @param {Data} data - The data result from NFT mints query.
* @returns {Object[]} An array of formatted minted NFTs' current balance
*/
const formatFunction = (data: Data) =>
data?.TokenTransfers?.TokenTransfer?.map(({ token }) => {
const { name, type, address, tokenBalances } = token;
const formattedAmount = tokenBalances[0]?.formattedAmount ?? 0;
return { name, type, address, formattedAmount };
})?.filter(
(arr, index, self) =>
index === self.findIndex((t) => t.address === arr.address)
);
/**
* @description Formats the NFT mints data.
*
* @example
* import { fetchQuery } from "@airstack/node";
*
* const { data } = await fetchQuery(query, variables);
* const res = formatFunction(data);
*
* @param {Data} data - The data result from NFT mints query.
* @returns {Object[]} An array of formatted minted NFTs' current balance
*/
const formatFunction = (data) =>
data?.TokenTransfers?.TokenTransfer?.map(({ token }) => {
const { name, type, address, tokenBalances } = token;
const formattedAmount = tokenBalances[0]?.formattedAmount ?? 0;
return { name, type, address, formattedAmount };
})?.filter(
(arr, index, self)