Get all NFTs for wallet address

Hi,

could someone please tell me how to query all NFTs for networks supported by Moralis for a specific wallet address?
Like:
const { data: NFTBalances } = useNFTBalances({
params: { address: walletAddress },
})

but without having to be authenticated?
Can I reopen an authenticated session before calling
const { data: NFTBalances } = useNFTBalances({
params: { address: walletAddress },
})

Sorry to mix two questions.

Cheers,
John

maybe this helps you:

https://docs.moralis.io/moralis-dapp/web3-sdk/account#getnfts

it also has example for react

Thanks for the fast reply, the react example seems to contain a lot of typos and semantic mistakes? Maybe you could fix it?

Is there any way to restore an old โ€œsessionโ€ with previous authentication in react in Moralis?

Also is there a way to do it without the account in Web3Api.account.getNfts - as the user is not logged in?

you need the user address somehow, it doesnโ€™t matter if it is authenticated or not, but if it is authenticated then you know the address

Hi, you are incredible fast, thanks.
I have the user address (wallet address) in a variable called walletAddress. Could you maybe give me an example of how to query the users NFTs having that address?

there is an example in documentation:

// get mainnet NFT transfers for the current user
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers();

// get BSC NFT transfers for a given address
// with most recent transactions appearing first
const options = {
  chain: "polygon",
  address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
  limit: "5",
};
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers(options);

mainly you set address parameter to walletAddress

1 Like

Thanks.

Different question: is it possible to store useMoralis in local storage of the browser and reuse? So reopen a session.
My problem is, that when I reload my page, the user gets logged out.

you can ask this question in a separate thread, I donโ€™t know the answer to it, I have no problem with vanilla js when the page is refreshed

1 Like