WalletConnect public RPC url Blocked by CORS policy because of rate limit

Good afternoon,

I hope someone can help me figure this stuff out:

I have been using the SDK for quite some time now and if I just rely on MetaMask to be present and active in the browser, everything works just fine. But when I add support for WalletConnect, for some reason, the SDK seems to start making connections via the Speedy Nodes to fetch blocks.

I have initialized the SDK with my Dapp server url, so I hoped it would use only my Moralis server for calls, but it does not (by default?).

This ONLY happens when the user has logged in via WalletConnect and I cannot seem to find a way to replace the speedy nodes URI with our own Moralis server as backend.

Because the SDK is making a lot of connections to the speedy nodes, I am hitting a rate limit very quickly which results in 500+ errors per minute (!) in the console. (Edit: it stops when I refresh the page)

Question 1: Any way I can change the speedy nodes requests to web3API requests since thats best practice?
Question 2: Any way to make the SDK stop calling eth_getBlockByNumber every X seconds?

Versions used:

  • Moralis @1.10.1
  • WalletConnect @1.7.8
Access to XMLHttpRequest at 'https://speedy-nodes-nyc.moralis.io/WalletConnect/bsc/mainnet' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Uncaught Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined

there are similar threads about this issue:

we don’t have a way now to replace that RPC url with a custom one

For those other people NOT using nodeJS like me, who also already read the articles @cryptokid mentioned but are also still wondering how to create an intermediate “fix” for this without any official release of the needed files from version 1.8.0-rc.0:

  1. Create a new dir and step into it:

mkdir walletconnect-1.8.0-rc.0 && cd walletconnect-1.8.0-rc.0/

  1. Install the 1.8.0-rc.0 version mentioned in other topics:

npm i @walletconnect/[email protected]

  1. Go to the dist directory:

cd node_modules/@walletconnect/web3-provider/dist/

  1. Copy the appropriate index.min.js (in my case umd/index.min.js) to your project’s assets/js dir:

cp umd/index.min.js ~/myproject/assets/js/web3-provider-1.8.0-rc.0.min.js

  1. Include that in your HTML under the moralis.js file:

<script src="./assets/js/web3-provider-1.8.0-rc.0.min.js"></script>

4 Likes