0

I'm using a combination of Thirdweb and Alchemy SDK to fetch all nfts in a connected wallet. Every example I've come across for Alchemy's getNftsForOwner function has the wallet address placed in the function like so:

const NFTs = await alchemy.nft.getNftsForOwner("0x0000");

I'm trying to figure out how to use the connected wallet in the function. I use Thirdweb's connect wallet and useAddress hook to get the address but I don't have to go that route if there is a better way to make it work.

My current setup is:

const router = useRouter();
const { walletAddress } = router.query;
const [NFTs, setNFTs] = useState<OwnedNftsResponse>()
const address = useAddress();
  
 


 useEffect( () => {
    async function grabber() {
        const NFTs = await alchemy.nft.getNftsForOwner(???);
      setNFTs(NFTs);
    }
    grabber();
  }, [NFTs]);

Every attempt I've tried to use the connected wallet address resulted in Error: 400: owner is a required request parameter

1 Answer 1

0

You need the wallet address to pass to the getNftsForOwner() function like so

const NFTs = getNftsForOwner(0xblahblahblahblah123blah)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.