💰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

  • 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 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

Code

query MyQuery {
  Wallet(
    input: {
      identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
      blockchain: ethereum
    }
  ) {
    domains(input: { limit: 200 }) {
      name
      isPrimary
    }
  }
}

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

Code

query MyQuery {
  Wallet(
    input: {
      identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
      blockchain: ethereum
    }
  ) {
    socials(input: { limit: 200, filter: { dappName: { _eq: lens } } }) {
      profileName
    }
  }
}

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

Code

query MyQuery {
  Wallet(
    input: {
      identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
      blockchain: ethereum
    }
  ) {
    socials(input: { limit: 200, filter: { dappName: { _eq: farcaster } } }) {
      profileName
    }
  }
}

Check If A User Have XMTP Enabled

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

Try Demo

Code

query MyQuery {
  Wallet(
    input: {
      identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
      blockchain: ethereum
    }
  ) {
    xmtp {
      isXMTPEnabled
    }
  }
}

Get User's Token Balances

You can use Wallet API to fetch all user's token (ERC20/721/1155) balances across Ethereum, Base, Degen Chain, and other Airstack-supported chains:

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

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

Code

query MyQuery {
  Wallet(
    input: {
      identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
      blockchain: ethereum
    }
  ) {
    tokenBalances {
      tokenAddress
      tokenId
      tokenType
      token {
        name
        symbol
      }
    }
  }
}

Get User's Token Transfers

You can use Wallet API to fetch all user's token (ERC20/721/1155) transfers across Ethereum, Base, Degen Chain, and other Airstack-supported chains:

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

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

Code

query MyQuery {
  Wallet(
    input: {
      identity: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
      blockchain: ethereum
    }
  ) {
    tokenTransfers {
      from {
        addresses
      }
      to {
        addresses
      }
      tokenAddress
      tokenId
      tokenType
      token {
        name
        symbol
      }
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?