β™‹Cross Chain Queries

Learn how you can do cross-chain queries using Airstack GraphQL API to fetch data more efficiently in a single request.

In GraphQL, you can call multiple queries in parallel in a single request as shown in Multiple Queries Execution.

As Airstack is a GraphQL API, it inherits this feature that enables you to call multiple APIs in one request, which is particularly useful for building cross-chain queries to fetch data across multiple Airstack-supported chains:

Try Demo

Code

query ERC20OwnedByLensProfiles {
  Ethereum: TokenBalances( # first query fetch Ethereum ERC20 balance
    input: {
      filter: {
        owner: {
          _in: [
            "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
            "vitalik.eth"
            "lens/@vitalik"
            "fc_fname:vitalik"
          ]
        }
        tokenType: { _eq: ERC20 }
      }
      blockchain: ethereum
      limit: 50
    }
  ) {
    TokenBalance {
      formattedAmount
      tokenAddress
      token {
        name
        symbol
      }
    }
  }
  Base: TokenBalances( # second query fetch Base ERC20 balance
    input: {
      filter: {
        owner: {
          _in: [
            "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
            "vitalik.eth"
            "lens/@vitalik"
            "fc_fname:vitalik"
          ]
        }
        tokenType: { _eq: ERC20 }
      }
      blockchain: base
      limit: 50
    }
  ) {
    TokenBalance {
      formattedAmount
      tokenAddress
      token {
        name
        symbol
      }
    }
  }
  Zora: TokenBalances( # third query fetch Zora ERC20 balance
    input: {
      filter: {
        owner: {
          _in: [
            "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
            "vitalik.eth"
            "lens/@vitalik"
            "fc_fname:vitalik"
          ]
        }
        tokenType: { _eq: ERC20 }
      }
      blockchain: zora
      limit: 50
    }
  ) {
    TokenBalance {
      formattedAmount
      tokenAddress
      token {
        name
        symbol
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding adding variables into your Airstack query, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?