我遇到了同样的错误,但不是在分叉主网上部署时而是在 Ropsten 网络上部署时!
如果我在 Remix 上手动执行命令,它就可以工作。

gas: 6000000编辑:通过在我的配置文件中添加字段解决了这个问题。

    eth_ropsten: {
      url: eth_ropsten.url,
      chainId: 3,
      gasPrice: 20000000000,
      gas: 6000000,
      accounts: { mnemonic: eth_ropsten.mnemonic }
    }

参考 https://github.com/NomicFoundation/hardhat/issues/2248