Learn how to use Airstack to traverse the ERC6551 tree, either upwards or downwards.
With ERC6551 accounts, NFT now has the capability to have an account on their own and perform writing actions to the blockchain as any other accounts on EVM. Thus, this also allows NFTs for the first time to own other assets, e.g. ERC20, ERC721, and ERC1155s.
Table Of Contents
Using Airstack, you can efficiently traverse the ERC6551 ownership tree, both upwards and downwards in just a single API call.
There are various use cases for traversing the ERC6551 ownership tree, which include but is not limited to:
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.
Traverse Up ERC6551 Tree By ERC6551 Account Address
Suppose that you know the ERC6551 account address X and would like to get the NFT that own the given ERC6551 account and the ERC6551 account that hold the mentioned NFT as shown in the chart below.
Then, you can use the Accounts API to do so with the following query by providing the ERC6551 account address X to the address filter input:
Try Demo
Code
To query the upper-level NFTs & ERC6551 accounts in the ERC6551 ownership tree, simply add more tokenBalances nesting inside the most nested nft field.
Suppose that you know the NFT X and would like to get the ERC6551 account that own the given NFT and the NFT that hold by the mentioned ERC6551 account, and the higher-level layer ERC6551 accounts & NFTs and so on, as shown in the chart below.
Then, you can use the TokenBalances API to do so with the following query by providing the NFT X's token address and token ID to the tokenAddress and tokenId filter input, respectively:
Try Demo
Code
To query the upper-level NFTs & ERC6551 accounts in the ERC6551 ownership tree, simply add more tokenBalances nesting inside the most nested nft field.
Suppose that you know the user's EOA wallet address X and would like to get all the NFTs and ERC6551 accounts own, either directly or indirectly, by the EOA as shown in the chart below.
Then, you can use the TokenBalances API to do so with the following query by providing the EOA address X to the owner filter input:
Try Demo
Code
To query the lower-level NFTs & ERC6551 accounts in the ERC6551 ownership tree, simply add more tokenBalances nesting inside the most nested address field.
Suppose that you know the user's EOA wallet address X and would like to get all the NFTs and ERC6551 accounts own, either directly or indirectly, by the EOA as shown in the chart below.
Then, you can use the Accounts API to do so with the following query by providing the NFT X's token address and token ID to the tokenAddress and tokenId filter input, respectively:
Try Demo
Code
To query the lower-level NFTs & ERC6551 accounts in the ERC6551 ownership, simply add more tokenBalances nesting inside the most nested address field.