What's the best way to fetch FA2 (NFT) owners? #1246
-
Hi. |
Beta Was this translation helpful? Give feedback.
Answered by
claudebarde
Dec 7, 2021
Replies: 1 comment
-
In general, FA2 contracts have a bigmap (sometimes called |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Dreitser
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In general, FA2 contracts have a bigmap (sometimes called
ledger
orbalances
) 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 returnsundefined
, otherwise, it returns the associated value.