Links
💰

Wallet

Learn how to use Airstack to fetch onchain and offchain data of a wallet, which includes, ENS, Lens, Farcaster, XMTP, token balances, etc.
Airstack provides easy-to-use Wallet API for enriching Web3 applications with onchain and offchain data of a wallet, which includes, ENS, Lens, Farcaster, XMTP, token balances, etc.

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 All User's ENS Domain

You can use Wallet API to fetch all user's ENS domains (including primary and non-primary):
If a user have more than 200 ENS domains resolved to the address, then it is recommended that you use the Domains API directly instead.

Try Demo

https://app.airstack.xyz/query/X7ltaCyncL
Show me all 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045's ENS domains

Code

Query
Response
query MyQuery {
Wallet(
input: {
identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
blockchain: ethereum
}
) {
domains(input: { limit: 200 }) {
name
isPrimary
}
}
}
{
"data": {
"Wallet": {
"domains": [
{
"name": "quantumexchange.eth",
"isPrimary": false
},
{
"name": "7860000.eth",
"isPrimary": false
},
{
"name": "vitalik.eth",
"isPrimary": true
}
// More ENS domain
]
}
}
}

Get All User's Lens Profiles

You can use Wallet API to fetch all user's Lens profiles:
If a user have more than 200 Lens profiles owned by the address, then it is recommended that you use the Socials API directly instead.
For more details, follow this guide here.

Try Demo

https://app.airstack.xyz/query/XR5DcbYEa4
Show me all 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045's Lens profiles

Code

Query
Response
query MyQuery {
Wallet(
input: {
identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
blockchain: ethereum
}
) {
socials(input: { limit: 200, filter: { dappName: { _eq: lens } } }) {
profileName
}
}
}
{
"data": {
"Wallet": {
"socials": [
{
"profileName": "lens/@vitalik"
}
]
}
}
}

Get All User's Farcaster Account

You can use Wallet API to fetch all user's Farcaster accounts:
If a user have more than 200 Farcaster accounts owned by the address, then it is recommended that you use the Socials API directly instead.

Try Demo

https://app.airstack.xyz/query/jKBmz9k6MM
Show me all 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045's Farcaster accounts

Code

Query
Response
query MyQuery {
Wallet(
input: {
identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
blockchain: ethereum
}
) {
socials(input: { limit: 200, filter: { dappName: { _eq: farcaster } } }) {
profileName
}
}
}
{
"data": {
"Wallet": {
"socials": [
{
"profileName": "vitalik.eth"
}
]
}
}
}

Check If A User Have XMTP Enabled

You can use Wallet API to check if a user has XMTP enabled:

Try Demo

https://app.airstack.xyz/query/p5J8Adtr3I
Check if 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 have XMTP enabled

Code

Query
Response
query MyQuery {
Wallet(
input: {
identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
blockchain: ethereum
}
) {
xmtp {
isXMTPEnabled
}
}
}
{
"data": {
"Wallet": {
"xmtp": [
{
"isXMTPEnabled": true
}
]
}
}
}

Get User's Token Balances

You can use Wallet API to fetch all user's token (ERC20/721/1155) balances across Ethereum, Polygon, Base, Zora:
If a user have more than 200 tokens on a chain, then it is recommended that you use the TokenBalances API directly instead.
For more details, follow this guide here.

Try Demo

https://app.airstack.xyz/query/vAEvtxhrfz
Show me token balances of 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Code

Query
Response
query MyQuery {
Wallet(
input: {
identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
blockchain: ethereum
}
) {
ethereum: tokenBalances(input: { blockchain: ethereum, limit: 200 }) {
tokenAddress
tokenId
tokenType
token {
name
symbol
logo {
external
small
medium
large
original
}
}
tokenNfts {
contentValue {
image {
original
extraSmall
small
medium
large
}
}
}
}
polygon: tokenBalances(input: { blockchain: polygon, limit: 200 }) {
tokenAddress
tokenId
tokenType
token {
name
symbol
logo {
external
small
medium
large
original
}
}
tokenNfts {
contentValue {
image {
original
extraSmall
small
medium
large
}
}
}
}
base: tokenBalances(input: { blockchain: base, limit: 200 }) {
tokenAddress
tokenId
tokenType
token {
name
symbol
logo {
external
small
medium
large
original
}
}
tokenNfts {
contentValue {
image {
original
extraSmall
small
medium
large
}
}
}
}
}
}
{
"data": {
"Wallet": {
"ethereum": [
{
"tokenAddress": "0x00000000366b8a1ec86d6c8e00c861bf2245d946",
"tokenId": "",
"tokenType": "ERC20",
"token": {
"name": "iPhone 15",
"symbol": "iPhone15",
"logo": {
"external": null,
"small": null,
"medium": null,
"large": null,
"original": null
}
},
"tokenNfts": null
}
// Other Ethereum tokens
],
"polygon": [
{
"tokenAddress": "0xf79631521c474984f17d656a05e0d317d8755b20",
"tokenId": "70811",
"tokenType": "ERC721",
"token": {
"name": "Layer Zero Ape",
"symbol": "LZA",
"logo": {
"external": null,
"small": null,
"medium": null,
"large": null,
"original": null
}
},
"tokenNfts": {
"contentValue": {
"image": {
"original": "https://assets.airstack.xyz/image/nft/lBSHruZl4WIKv5+1BA90LMdoLsBUrCcvJf2bNOxI7r8NPtinI8YIZ5/juQRjVF3gpq5MFmChzZhoI2JV/dZ1Aw==/original_image.png",
"extraSmall": "https://assets.airstack.xyz/image/nft/lBSHruZl4WIKv5+1BA90LMdoLsBUrCcvJf2bNOxI7r8NPtinI8YIZ5/juQRjVF3gpq5MFmChzZhoI2JV/dZ1Aw==/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/lBSHruZl4WIKv5+1BA90LMdoLsBUrCcvJf2bNOxI7r8NPtinI8YIZ5/juQRjVF3gpq5MFmChzZhoI2JV/dZ1Aw==/small.png",
"medium": "https://assets.airstack.xyz/image/nft/lBSHruZl4WIKv5+1BA90LMdoLsBUrCcvJf2bNOxI7r8NPtinI8YIZ5/juQRjVF3gpq5MFmChzZhoI2JV/dZ1Aw==/medium.png",
"large": "https://assets.airstack.xyz/image/nft/lBSHruZl4WIKv5+1BA90LMdoLsBUrCcvJf2bNOxI7r8NPtinI8YIZ5/juQRjVF3gpq5MFmChzZhoI2JV/dZ1Aw==/large.png"
}
}
}
}
// Other Polygon tokens
],
"base": [
{
"tokenAddress": "0x6e30433b8c65e76fa095e85260a244b3c3bc1865",
"tokenId": "265",
"tokenType": "ERC721",
"token": {
"name": "Base Echo",
"symbol": "$",
"logo": {
"external": null,
"small": null,
"medium": null,
"large": null,
"original": null
}
},
"tokenNfts": {
"contentValue": {
"image": {
"original": "https://assets.airstack.xyz/image/nft/8453/8ptb4/bkF79jKGc/p1otcqwQSv+qMZ6PvIpudahqBysb50fH7Q/xnptwoac3JTkz52VW+xrBXzdvFFCzMQXqNw==/original_image.png",
"extraSmall": "https://assets.airstack.xyz/image/nft/8453/8ptb4/bkF79jKGc/p1otcqwQSv+qMZ6PvIpudahqBysb50fH7Q/xnptwoac3JTkz52VW+xrBXzdvFFCzMQXqNw==/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/8453/8ptb4/bkF79jKGc/p1otcqwQSv+qMZ6PvIpudahqBysb50fH7Q/xnptwoac3JTkz52VW+xrBXzdvFFCzMQXqNw==/small.png",
"medium": "https://assets.airstack.xyz/image/nft/8453/8ptb4/bkF79jKGc/p1otcqwQSv+qMZ6PvIpudahqBysb50fH7Q/xnptwoac3JTkz52VW+xrBXzdvFFCzMQXqNw==/medium.png",
"large": "https://assets.airstack.xyz/image/nft/8453/8ptb4/bkF79jKGc/p1otcqwQSv+qMZ6PvIpudahqBysb50fH7Q/xnptwoac3JTkz52VW+xrBXzdvFFCzMQXqNw==/large.png"
}
}
}
}
// Other Base tokens
]
}
}
}

Get User's Token Transfers

You can use Wallet API to fetch all user's token (ERC20/721/1155) transfers across Ethereum, Polygon, Base, and Zora:
If a user have more than 200 token transfers on a chain, then it is recommended that you use the TokenTransfers API directly instead.
For more details, follow this guide here.

Try Demo

https://app.airstack.xyz/query/CMQykW6gbS
show me all token transfers from or to 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Code

Query
Response
query MyQuery {
Wallet(
input: {
identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
blockchain: ethereum
}
) {
ethereum: tokenTransfers(
input: {
blockchain: ethereum
limit: 200
filter: {
_nor: {
from: { _eq: "0x0000000000000000000000000000000000000000" }
to: { _eq: "0x0000000000000000000000000000000000000000" }
}
}
}
) {
from {
addresses
domains {
name
isPrimary
}
socials {
profileName
dappName
}
xmtp {
isXMTPEnabled
}
}
to {
addresses
domains {
name
isPrimary
}
socials {
profileName
dappName
}
xmtp {
isXMTPEnabled
}
}
tokenAddress
tokenId
tokenType
token {
name
symbol
logo {
external
small
medium
large
original
}
}
tokenNft {
contentValue {
image {
original
extraSmall
small
medium
large
}
}
}
}
polygon: tokenTransfers(
input: {
blockchain: polygon
limit: 200
filter: {
_nor: {
from: { _eq: "0x0000000000000000000000000000000000000000" }
to: { _eq: "0x0000000000000000000000000000000000000000" }
}
}
}
) {
from {
addresses
domains {
name
isPrimary
}
socials {
profileName
dappName
}
xmtp {
isXMTPEnabled
}
}
to {
addresses
domains {
name
isPrimary
}
socials {
profileName
dappName
}
xmtp {
isXMTPEnabled
}
}
tokenAddress
tokenId
tokenType
token {
name
symbol
logo {
external
small
medium
large
original
}
}
tokenNft {
contentValue {
image {
original
extraSmall
small
medium
large
}
}
}
}
base: tokenTransfers(
input: {
blockchain: base
limit: 200
filter: {
_nor: {
from: { _eq: "0x0000000000000000000000000000000000000000" }
to: { _eq: "0x0000000000000000000000000000000000000000" }
}
}
}
) {
from {
addresses
domains {
name
isPrimary
}
socials {
profileName
dappName
}
xmtp {
isXMTPEnabled
}
}
to {
addresses
domains {
name
isPrimary
}
socials {
profileName
dappName
}
xmtp {
isXMTPEnabled
}
}
tokenAddress
tokenId
tokenType
token {
name
symbol
logo {
external
small
medium
large
original
}
}
tokenNft {
contentValue {
image {
original
extraSmall
small
medium
large
}
}
}
}
}
}
{
"data": {
"Wallet": {
"ethereum": [
{
"from": {
"addresses": ["0xd8da6bf26964af9d7eed9e03e53415d37aa96045"],
"domains": [
{
"name": "vitalik.eth",
"isPrimary": true
}
// Other ENS Domain
],
"socials": [
{
"profileName": "vitalik.eth",
"dappName": "farcaster"
},
{
"profileName": "lens/@vitalik",
"dappName": "lens"
}
],
"xmtp": [
{
"isXMTPEnabled": true
}
]
},
"to": {
"addresses": ["0xd8b75eb7bd778ac0b3f5ffad69bcc2e25bccac95"],
"domains": [
{
"name": "toastmybread.eth",
"isPrimary": true
},
{
"name": "daerbymtsaot.eth",
"isPrimary": false
}
],
"socials": null,
"xmtp": [
{
"isXMTPEnabled": true
}
]
},
"tokenAddress": "0xc791c23da1161f8259c9094b65cf13f9d891a892",
"tokenId": "606",
"tokenType": "ERC721",
"token": {
"name": "Mars Mining Company",
"symbol": "MARS",
"logo": {
"external": null,
"small": null,
"medium": null,
"large": null,
"original": null
}
},
"tokenNft": {
"contentValue": {
"image": null
}
}
}
// Other Ethereum token transfers
],
"polygon": [
{
"from": {
"addresses": ["0xd8da6bf26964af9d7eed9e03e53415d37aa96045"],
"domains": [
{
"name": "vitalik.eth",
"isPrimary": false
}
// Other ENS domains
],
"socials": [
{
"profileName": "vitalik.eth",
"dappName": "farcaster"
},
{
"profileName": "lens/@vitalik",
"dappName": "lens"
}
],
"xmtp": [
{
"isXMTPEnabled": true
}
]
},
"to": {
"addresses": ["0xd8da6bf26964af9d7eed9e03e53415d37aa96045"],
"domains": [
{
"name": "quantumexchange.eth",
"isPrimary": false
}
// Other ENS domains
],
"socials": [
{
"profileName": "vitalik.eth",
"dappName": "farcaster"
},
{
"profileName": "lens/@vitalik",
"dappName": "lens"
}
],
"xmtp": [
{
"isXMTPEnabled": true
}
]
},
"tokenAddress": "0x3d43e92c28e7635ef969b61bb420ab6d55fb1bb8",
"tokenId": "2026",
"tokenType": "ERC721",
"token": {
"name": "Cult Vitalik",
"symbol": "VITALIK",
"logo": {
"external": null,
"small": null,
"medium": null,
"large": null,
"original": null
}
},
"tokenNft": {
"contentValue": {
"image": {
"original": "https://assets.airstack.xyz/image/nft/Kjas71EGE19T8JWjr7VjMPqQt4gskyNf6gvlS8eXiHnEIdBrrPBl0jCxYED5XhTLxuwn2atJtKHv6P1z7u5fgg==/original_image.png",
"extraSmall": "https://assets.airstack.xyz/image/nft/Kjas71EGE19T8JWjr7VjMPqQt4gskyNf6gvlS8eXiHnEIdBrrPBl0jCxYED5XhTLxuwn2atJtKHv6P1z7u5fgg==/extra_small.png",
"small": "https://assets.airstack.xyz/image/nft/Kjas71EGE19T8JWjr7VjMPqQt4gskyNf6gvlS8eXiHnEIdBrrPBl0jCxYED5XhTLxuwn2atJtKHv6P1z7u5fgg==/small.png",
"medium": "https://assets.airstack.xyz/image/nft/Kjas71EGE19T8JWjr7VjMPqQt4gskyNf6gvlS8eXiHnEIdBrrPBl0jCxYED5XhTLxuwn2atJtKHv6P1z7u5fgg==/medium.png",
"large": "https://assets.airstack.xyz/image/nft/Kjas71EGE19T8JWjr7VjMPqQt4gskyNf6gvlS8eXiHnEIdBrrPBl0jCxYED5XhTLxuwn2atJtKHv6P1z7u5fgg==/large.png"
}
}
}
}
// Other Polygon token transfers
],
"base": [
{