Skip to content

What's the best way to fetch FA2 (NFT) owners? #1246

Answered by claudebarde
Dreitser asked this question in Q&A
Discussion options

You must be logged in to vote

In general, FA2 contracts have a bigmap (sometimes called ledger or balances) whose keys are the users’ addresses together with a token id if that’s relevant to the use case.
You can get the storage of the contract with await contract.storage() and check if the user’s address is a key of the bigmap, for example, await storage.ledger.get(USER_ADDRESS). If there is no matching key, the promise returns undefined, otherwise, it returns the associated value.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Dreitser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants