Multiple executeFunction calls cause MetaMask - RPC Error: Internal JSON-RPC error. 32005 rate limit exceed

Hello,

i just migrated from useDapp to moralis. im Using await Moralis.executeFunction(options). When doing this multiple times in a row, from time to time only sometimes for some reason, i get this inpage.js:1 MetaMask - RPC Error: Internal JSON-RPC error. 32005

Which seems to be related to a rate limit exceed.

I already did a lot of research. any ideas on this one? Thanks!

 const fetchPendingRewards = () => {
        if (walletAddress && isAuthenticated) {
            const fetch = async () => {
                const options = {
                    contractAddress: stakingAddress,
                    functionName: 'pendingReward',
                    abi: StakingContractProvider.abi,
                    params: {_user: walletAddress},
                }
                try {
                    // @ts-ignore
                    const response = await Moralis.executeFunction(options)
                    if (response && BigNumber.isBigNumber(response)) {
                        setPendingReward(Number(formatUnits(response, 18)))
                    }
                } catch (e) {
                    console.log('pendingReward', e)
                }
            }
            fetch()
        } else {
            setPendingReward(0)
        }
    }

it looks like a rate limit error
a RPC url will be used to make those calls, the one that usually is added in metamask, and there has to be a rate limit for those RPC urls as if there will be no rate limit then someone could use it to make thousands of requests per second

does this mean the problem might be caused by firing too many reuests? its only 8 in a row. tbis should be no problem right?

It shouldnโ€™t be a problem unless youโ€™re making requests too quickly. How long does it take for all of them?

fixed:

for reading we use

const response = await Moralis.Web3API.native.runContractFunction(options)

for writing we use

useWeb3ExecuteFunction()

using execute function for reading will use meta mask rcp which of course is limited

1 Like