javascriptethereumweb3jstrufflejson-rpc

How to configure a different polling interval in Truffle?


How does one configure either Truffle itself, or Truffle's HDWalletProvider such that the poll interval is different?

I would like my Truffle instance to be less "chatty" over JSON-RPC, when it has submitted a transaction and is waiting for a result, be decreasing the polling interval from it's default value.

I was not able to find this option in the following documentation:


In truffle-config.js, within networks:

    testnet: {
      provider: () => new HDWalletProvider(
        SEED_PHRASE,
        'https://localhost:4444/',
      ),
      gasPrice: Math.floor(GAS_PRICE),
      networkCheckTimeout: 1e3,
    },

Solution

  • Patched @truffle/hdwallet-provider to add pollingInterval. This is now available in truffle@5.1.52.

    Patched truffle to add deploymentPollingInterval. This is now available in truffle@5.1.53.

    Example:

        testnet: {
          provider: () => new HDWalletProvider({
            mnemonic: {
              phrase: SEED_PHRASE,
            },
            providerOrUrl: 'http://localhost:4444',
            pollingInterval: 8000,
          }),
          gasPrice: Math.floor(GAS_PRICE),
          networkCheckTimeout: 8000,
          deploymentPollingInterval: 8000,
        },
    

    When unspecified, the default value for pollingInterval and deploymentPollingInterval are both 4000; so the above example has the effect of making it half as "chatty" over JSON-RPC, when polling for blocks, and when running truffle migrate.