Web3 API error for devchain while calling SDK functions

Hi guys. I’m being unable to call the functions getNFTs and getNFTsForContract in a hardhat local dev chain. I’ve created a Local Dev Chain Server in Moralis and synced the local chain with frpc, which seems to be working because I see the transactions I’ve done locally in the Server Dashboard .

I’m using React-Moralis inside a Next.js app, initialized (in _app.js file) with <MoralisProvider appID={...} serverUrl={...}>

The versions in my package.json are:

"moralis": "^0.0.124",
"react-moralis": "^0.2.8"

The endpoint is called when the user clicks a button to get the NFT info:

const { authenticate, isAuthenticated } = useMoralis()
const web3Api = useMoralisWeb3Api()

<button onClick={
	isAuthenticated ?
    async () => {
        const result = await web3Api.account.getNFTs({
            chain: 'dev',
        })
        console.log(result)
    }
    :
    () => authenticate()
}>

The following is the error I get in the Log section of the Server Dashboard. For the chain param, I’ve tried "localdevchain", "dev", "ganache", "hardhat", but the same happens:

2021-11-10T22:17:10.428Z - Error: Web3 API error while calling /:address/nft
    at fetch (/moralis-server/lib/cloud-code/plugins/convenience/web3Api.js:128:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

2021-11-10T22:17:10.426Z - Failed running cloud function getNFTs for user undefined with:
  Input: {"chain":"dev","address":"0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199"}
  Error: {"message":"Web3 API error while calling /:address/nft","code":141}

Thanks for your time!

Hi @juanilarregui

Currently, web3API doesn’t work for local chain. But its support will be added back soon.

Hi @Yomoo, thanks for your response.

I’m new to Moralis. By your expression “added back soon”, do you mean it was supported but it’s temporarily unavailable? I mean, are we talking hours, days, weeks?

I just ask because I have a deadline in a week and I want to know how to design my site.

Thanks!

You can deploy to a testnet where web3api works fine. It could be weeks until support is added, it didn’t work for weeks.

2 Likes

Thanks! will do that.