Too much request "eth_BlockNumber". How to reduce?

We use useDApp on the project. We have a lot of requests. 2k users created 2k requests every second. Given that the “Team” plan gives access to 1 million requests, I think that in this case our node will down in about 10 minutes. I’m sure it shouldn’t be like that. Maybe someone came across such a feature of the useDApp library and knows how to solve it?

Welcome das3d!

If you’re using Truffle’s HDWalletProvider and seeing big numbers of requests made by eth_getBlockByNumber or/and eth_BlockNumber most likely this is coming from HDWalletProvider which does constant block polling.
Some suggestions below:

  1. truffle-hdwallet-provider is deprecated, try to use the current one which might be better at block polling.
    In most cases it should be enough to replace:
    const HDWalletProvider = require('truffle-hdwallet-provider');
    const HDWalletProvider = require("@truffle/hdwallet-provider");

If that doesn’t help, see pollingInterval param that you can use to control it:

  1. Use HDWalletProvider only where needed, eg. deploying or calling contract methods. For anything else (like sending tx) you can use either a Websocket or HTTP provider, example for HTTP:
const web3 = new Web3(new Web3.providers.HttpProvider(`<INFURA_PROJECT_ID>`));

Tips from this article below:

Another post regarding the same issue:

Kind regards,
Alex | Infura Support

Hi Apdan!

We use ethers.js and useDApp library.


Any chance you can share with us a public github repo of your project? I would like to see more of the code you are running, maybe we can remove some instances of block polling.

Kind regards,
Alex | Infura Support

I am having the same problem. I am creating the React native dapp, after the first transaction it starts these requests and blows up the server, and very difficult to make another transaction, any solution? I am using web3.js with wallet connect web3Provider.