Links

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

Try Demo

https://app.airstack.xyz/query/Mf7KH1MM0o
Show ERC20 tokens on Ethereum, Polygon, Base, and Zora owned by users

Code

Query
Response
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
}
}
}
Polygon: TokenBalances( # second query fetch Polygon ERC20 balance
input: {
filter: {
owner: {
_in: [
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
"vitalik.eth"
"lens/@vitalik"
"fc_fname:vitalik"
]
}
tokenType: { _eq: ERC20 }
}
blockchain: polygon
limit: 50
}
) {
TokenBalance {
formattedAmount
tokenAddress
token {
name
symbol
}
}
}
Base: TokenBalances( # third 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( # fourth 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
}
}
}
}
{
"data": {
"Ethereum": {
"TokenBalance": [
{
"formattedAmount": 10860.787005472,
"tokenAddress": "0x6390ee51738652b4f22c20f0fd02275cbd5ff685",
"token": {
"name": "From Vitalik",
"symbol": "Vitalik"
}
},
// Other Ethereum ERC20s
]
},
"Polygon": {
"TokenBalance": [
{
"formattedAmount": 1,
"tokenAddress": "0xff99afd7dd09988d76c4aaab5798216617335b96",
"token": {
"name": "Acces Liquid-ether.com",
"symbol": "Acces Liquid-ether.com to claim rewards"
}
},
// Other Polygon ERC20s
]
},
"Base": {
"TokenBalance": [
{
"formattedAmount": 1420,
"tokenAddress": "0x4ed4e862860bed51a9570b96d89af5e1b0efefed",
"token": {
"name": "Degen",
"symbol": "DEGEN"
}
},
// Other Base ERC20s
]
},
"Zora": {
"TokenBalance": [
{
"formattedAmount": 100,
"tokenAddress": "0x6c99db030dcc2c4d2e464c481812db078f4b30cc",
"token": {
"name": "ZOO",
"symbol": "zoo"
}
},
// Other Zora ERC20s
]
}
}
}

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