To query all of the holders of a particular collection with their respective items, run the following query:
There will be duplicates between the staked_owner
and owner
. Unfortunately, GraphQL does not allow for the removal of these duplicates but the filtering can be done within your application with a simple JS function like the following:
const allOwners = response.data.aptos.nft_state.flatMap((i) => [i.owner, i.staked_owner]);
const uniqueWallets = [...new Set(allOwners)];
<aside> 💡 Remember: You can copy these queries and vars into our GraphQl API Explorer to see the results: https://www.indexer.xyz/api-explorer
</aside>