Unable to conduct transactions once connected to the wallet using WalletConnect

We use moralis to connect to the wallet, and once we connected to our wallet (MetaMask) through WalletConnect we got these errors in the console log. Thus we can not conduct any transactions.

  1. “Access to XMLHttpRequest at ‘https://speedy-nodes-nyc.moralis.io/WalletConnect/avalanche/testnet’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”
  2. “POST https://speedy-nodes-nyc.moralis.io/WalletConnect/avalanche/testnet net::ERR_FAILED”
  3. “Uncaught Error: PollingBlockTracker - encountered an error while attempting to update latest block:
    undefined
    at PollingBlockTracker._performSync (polling.js:51:1)”

We used these libraries -
“moralis”: “^1.3.2”,
“react-moralis”: “^1.3.1”,
“web3”: “1.7.0”

Hi,
There is a limit of how many requests can be done to those specific speedy node urls per minute for an IP

If you wait some time and try again then it should work.

Hi,
Thank you for the reply. I created a test server in a pro price plan of moralis and configured it in my application, but I still got the same error messages.

that limit doesn’t depend on your plan, it is a limit per IP, for any IP, so that someone can not abuse that public RPC url.

The RPC URL that we are using is not a public one. It is a moralis-provided RPC URL that is specific to our account. Also, we are using a pro plan and have not used many requests.
Also, I can use this RPC URL for minting NFTs/burning NFTs without any rate issues. The only problem when using WalletConnect it gives the errors mentioned above.

Have you tried an RPC URL from another provider? To help determine if it’s a Moralis node issue or something else.

Thank you for the reply. I’ll try this and meanwhile, I found this there it suggests that the issue is in the moralis servers. What are your thoughts on that?

Thanks for that, I was able to eventually replicate the issue using this demo on AVAX testnet. Changing the RPC in node_modules\moralis\lib\browser\Web3Connector to the public one did fix the connection.

One thing in common between this project and yours are the outdated Moralis libraries which may be the problem. I will try this with a new updated project tomorrow.

where in code are you setting the custom RPC url if it is not a public one?

I updated the moralis libraries to the newest stable versions, but I’m still getting those same errors. And could you please tell me which file inside the Web3Connector folder I need to change the RPC URL.

we are using a moralis speedy-nodes RPC URL. And this is an example where we used RPC URL. (NEXT_PUBLIC_NETWORK_ENDPOINT is the RPC URL)

const provider = new ethers.providers.JsonRpcProvider(process.env.NEXT_PUBLIC_NETWORK_ENDPOINT)

  const getTokenData = async(contractAddress: string, tokenId: string): Promise<iTokenSaleInfo> => {
    const contract = new ethers.Contract(contractAddress, abi, provider);
    const seller: string = await contract.owner();
    const owner: string = await contract.ownerOf(Number(tokenId));

    return {
      seller: {
        accountId: seller.toLowerCase(),
        isVerified: true
      },
      owners: [{
        accountId: owner.toLowerCase(),
        isVerified: false
      }]
    }
  }

It’s the MoralisRpcs.js file, you can change it there for whichever chainId you’re using.

I tried changing the RPC URL in the MoralisRpcs.js file. It did not fix the issue. I implemented a simple react app to reproduce the issue. You can access it here.

Strangely I am authenticating ok with that repo on my end on Fuji/AVAX testnet. Even using your server settings.

Do you mind deploying to Netlify or Vercel?

The authentication process works fine for me too, but when I conduct a transaction get the error. Most of the time the error occurred in the second or third transaction and the transactions before that execute fine. Did you able to successfully set an item for sale in the marketplace?

If I try “set sale item” I get an error of cannot estimate gas... and then the CORS issues as you have encountered.

But again if I change the RPC in MoralisRpcs.js to (does doing this still not get past the CORS issues in your local development?):

43113: "https://api.avax-test.network/ext/bc/C/rpc",

This gets around the CORS errors, although it still results in the same cannot estimate gas... execution reverted: ERC721: owner query for nonexistent token.

yes I also tried changing the RPC in MoralisRpcs.js to

43113: "https://api.avax-test.network/ext/bc/C/rpc",

but it still does not get past the CORS issues.

So the RPC is changing in the error message? May be an issue with your connection, you can try using a VPN.

I’m able to fix the issue by changing the RPC in MoralisRpcs.js to our custom RPC Url. Is there a way to pass the speedyNodeKey to the module?

there isn’t a way now from what I know

there is a rate limit for the public RPC url, if you wait few minutes and try again later it works to make a transaction?