I’ve been working with Alchemy’s getNFTs API to fetch NFTs for a specific wallet. The API gives me a contract address for each NFT, but I need more info about the contract itself. I’m looking for details like the owner and the total number of tokens.
I’ve looked through the API docs, but I can’t find an endpoint that gives me this extra contract info. Does anyone know how to get these details using Alchemy’s web3 toolkit?
Here’s a simplified example of what I’m working with:
const alchemy = new Alchemy(config);
const nfts = await alchemy.getNFTs({ owner: walletAddress });
// I can access the contract address like this:
const contractAddress = nfts[0].contract.address;
// But how do I get more info about the contract?
const contractDetails = await alchemy.getSomeContractInfo(contractAddress);
yo PixStar54, i’ve been messing with alchemy too. for contract deets, try using etherscan’s API alongside alchemy. it’s got endpoints for contract info including owner and token count. might need to juggle APIs, but it works. something like:
I’ve faced a similar challenge and found that Alchemy’s NFT API doesn’t directly provide all contract details. However, you can use a combination of Alchemy endpoints to get the information you need.
For the contract owner, you can use the getTransactionReceipt method to find the address that deployed the contract. As for the total number of tokens, the getNFTsForContract endpoint can help. It returns metadata including the totalSupply for ERC721 contracts.
hey there PixStar54! i’ve been tinkering with alchemy’s nft stuff too and ran into similar roadblocks. have you considered using the getContractMetadata endpoint? it might give you some of that extra info you’re after.
this should give you a bunch of useful details about the contract. as for the owner, that’s a bit trickier. you might need to dig into the contract’s ABI or use etherscan’s API if alchemy doesn’t have it.
btw, have you tried any other web3 libraries? curious if you’ve found any that handle this stuff better than alchemy. let me know what you end up figuring out!