A JavaScript question, how do I get the nftIDs an address owns for a specific collection?
Like, I have the collection address and the user's address
How do I query the Blockchain to get the nftIDs that address owns?

Sep 9, 2022, 6:02 AM
u need to use a web3 library like web3 js or ethers js to query the blocc chain
and u need a node to actually communicate w/ the blocc chain
u can setup a node on ur computer which will take a day to download the entire blocc chain or you can sign up for an account at alchemy and use their nodes for free
Sep 9, 2022, 6:25 AM
Daa fu'c
I don't need something that complicated
I just need to know what function or a way to call some functions to get the data
Or Alchemy? Can they generate that data for me?
Sep 9, 2022, 6:29 AM
He don't need a node, he can just call the read function
Sep 9, 2022, 6:29 AM
o if u just want to read my bad
sending a txn much more involved
lol
but still
Sep 9, 2022, 6:30 AM
Yeah. I am looking at which read function to call
Cause so far, just ownerOf (which needs the nftID in which case I don't have)
And the balanceOf (which returns numeric number of NFTs owned, not the ID)
Sep 9, 2022, 6:30 AM
to use web3 js u have to initialize it w/ a provider
Sep 9, 2022, 6:30 AM
It's gonna be gasless
Yea, I got that up to this point
It's the actual function reading that I need help with
Sep 9, 2022, 6:31 AM
ur contract needs to be enumerable
https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#IERC721Enumerable-tokenOfOwnerByIndex-address-uint256-
tokenOfOwnerByIndex(address owner, uint256 index) → uint256
and balanceOf(address owner) → uint256 balance
those 2 funds give u waht u need
use a 4 loop
Sep 9, 2022, 6:32 AM
Contract isn't mine
It's a Collection's contract
Like Bored Ape Yacht Club NFTs
Sep 9, 2022, 6:33 AM
if its not ERC721Enumerable ur out of luck
Sep 9, 2022, 6:34 AM
Hmm 🤔
I will implement this in my own contract right?
Sep 9, 2022, 6:34 AM
yes
u have to do it the ugly way
Sep 9, 2022, 6:34 AM
Let me review the function then
Thank you
Sep 9, 2022, 6:35 AM

© 2024 Draquery.com All rights reserved.