MetaMask - RPC Error: JsonRpcEngine: Response has no error or result for request:

Hello. I am using simple code from doc:

public async getUserRooms(userAddress: string): Promise<string[] | any> {
    try {
      return await Moralis.executeFunction({
          ...this.defaultContractOptions,
          functionName: "getUserRooms",
          params: {
            userAddress: userAddress,
          },
        }
      );
    } catch (e: any) {
      console.log("getUserRooms", e)
    }
    
  }

For get data from contract. and receive error:

After page is reloaded, all works well. In some time have error again. Any ideas?

I don’t know. I assume that MetaMask extension is loaded and you called Moralis.enableWeb3 before that


Take a look this?
Also, the requests is pending a lot of time, then receive this error.

I don’t know, what would be the difference after the page loads?

I guess that you already used await Moralis.enableWeb3()

sure it’s enabled.
I also saw that, it happen only when I call await Moralis.executeFunction
But when I call await Moralis.Web3API.native.runContractFunction(options) error not happen.

this doesn’t use metamask, it is expected to work, this works also when web3 is not enabled

GitHub issue on this.

Are you using executeFunction after you have authenticated?

not always, sometimes only after web3 enabled.

So do you think this is a Mertamask issue or a Moralis prob? (I am getting the same issue since this morning)

I am sure 100% it’s moralis, cause web3 works well.

what you mean with web3 working well? executeFunction uses ethers directly

I replaced web3 instead of ethers, and still not receive error.

you mean that using ethers/web3 directly to call a function works and using Moralis.executeFunction sometimes doesn’t work for same contract function?

I see, executeFunction should always be run after web3 is enabled (or a valid provider exists) - it won’t work otherwise.

I did not touch an app during 3 days. Today open and receive new error:

Does anybody knows 100% working library for angular?

This thread may help with understanding what is causing that error.

ethers.js or web3.js should be fine in an Angular app, if you don’t have issues with web3.js (compared to Moralis/ethers.js) then you can stick with that.