Ropsten Testnet get NFTs

Hello, I want to get all of the NFTs for a wallet on the ropsten testnet, however the code is giving me this error

Uncaught (in promise) Error: Invalid or unsupported chain “ropsten” at handleError

This is my code:

const options = {chain: “ropsten”, address: ‘0x94Fb04A09022D48007e55Bbab7f2e5fabce08ffb’}
const nfts = await Moralis.Web3.getNFTs(options)

Is that really how you are calling it?
Shouldn’t it be await Moralis.Web3API.account.getNFTs()?

Also just try “0x3” instead of ropsten might work

Yes it works for the eth and matic main nets it doesnt work for the ropsten testnet

Error: Invalid or unsupported chain “0x3”
at handleError

How about “testnet”? Also do you have ropsten selected on the server you are using?

As @kone mentioned, it should be Moralis.Web3API.account.getNFTs() which works fine.

const options = {
    chain: "ropsten",
    address: "0x94Fb04A09022D48007e55Bbab7f2e5fabce08ffb",
};
const nfts = await Moralis.Web3API.account.getNFTs(options);
console.log(nfts);

I dont want to use moralis for the authentication part. I just want to use it to get all the NFTs

You don’t have to? Pretty sure it should work even if you authenticate with something else or not authenticate at all

Whats the entire code snippet, because this is the error:

Uncaught (in promise) Error: Web3Api not initialized, run Moralis.start() first

You haven’t run Moralis.start()?

I have but now the entire page is just white and wont load

Moralis.start({ serverUrl: “SERVER_URL”, appId: “APP_ID” })

What are the errors you are getting?

Uncaught NoMoralisContextProviderError: Make sure to only call useMoralis within a
at NoMoralisContextProviderError.ReactMoralisError [as constructor]

import Moralis from ‘moralis’
import { useMoralisWeb3Api } from “react-moralis”;
Moralis.start({ serverUrl: “SERVER_URL”, appId: “APP_ID” })

function Vault() {

const Web3Api = useMoralisWeb3Api()

useEffect(async() => {
const options = {chain: “ropsten”, address: ‘0x94Fb04A09022D48007e55Bbab7f2e5fabce08ffb’}
const nfts = await Web3Api.account.getNFTs(options) …

oh I didn’t know you were using react (sorry for the late reply btw).
Check this (click on the react tab if something else is selected for the code example)
https://docs.moralis.io/moralis-dapp/web3-sdk/account#getnfts

if you are using it in react, check the doc https://docs.moralis.io/moralis-dapp/connect-the-sdk/connect-with-react. You have to wrap the App component with MoralisProvider.

1 Like