hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Allow custome maxPriorityFeePerGas in hardhat.config.js (@hardhat/ethers)

Open Amxx opened this issue 4 years ago • 5 comments

Ethers.js provider usually inherits from the abstract-provider class. This class includes a getFeeData() function, which sets the maxPriorityFeePerGas to 2.5gwei at the provider level. This can be overridden to change the value.

It is really useful to be able to set such values at the provider (or signer) level rather than in each transaction. This makes sure any oversight is covered, and also that these settings are applied if we pass the signer/provider to a module (like @openzeppelin/upgrades).

This works well with ethers alone, but the provider that comes with @hardhat/ethers is different:

  • it is a proxy, which doesn't let us override functions like getFeeData
  • for some reason, it doesn't use getFeeData, and apply its own maxPriorityFeePerGas of 1gwei
  • AFAIK, and as far as the documentation is concerned, there is no way to change that priority fee in the config.

My solution has been to wrap network.provider into an ethers.provider.FallbackProvider, but then I lose control over the signer (JSONRPC signers cannot be connected to another provider easily) ... and its a huge mess

Request:

In hardhat.config.jon, allow setting a custom maxPriorityFee per network

module.exports = {
  networks: {
    mainnet: {
      url: process.env.MAINNET_NODE,
      accounts: { mnemonic: process.env.MAINNET_MNEMONIC },
      maxPriorityFee: ethers.utils.parseUnits('2.51', 'gwei'). // ← THIS
    }
  }
}

Amxx avatar Sep 08 '21 09:09 Amxx

Hi @Amxx, thanks for opening this.

This would be an interesting feature, but I'm not quite sure about the implementation. Is getFeeData meant to be be overridden? Or would it be monkey-patching? (We are already doing that for ethers, tbh, but we want to avoid doing it even more :sweat_smile: )

fvictorio avatar Sep 13 '21 13:09 fvictorio

I'm not sure about overriding getFeeData.

If that can be set in the config file, overriding would not be require anyway

Amxx avatar Sep 13 '21 18:09 Amxx

Agree this is needed.

Ideally I'd always deploy with high priority fees.

silvercondor avatar Sep 21 '21 04:09 silvercondor

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Jul 26 '22 20:07 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Aug 02 '22 20:08 github-actions[bot]