HttpProviderError when deploying contract from Hardhat

:1234: Code to reproduce

executed command = npx hardhat run --network mumbai .\scripts\prepare-upgrade-ENFT.script.js
I am getting ProviderError: HttpProviderError when upgrading my smart contract. I tried changing the RPCs too, but still i get this issue.
Below is my hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-chai-matchers");
require("@nomiclabs/hardhat-ethers");
require("@openzeppelin/hardhat-upgrades");
require("@nomiclabs/hardhat-etherscan");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
    defaultNetwork: "localhost",
    networks: {
        hardhat: {},
        mumbai: {
            url: "RPC_URL",
            //url: "https://matic-mumbai.chainstacklabs.com/",
            //url: "https://rpc-mumbai.maticvigil.com",
            accounts: [
                "PRIVATE_KEY",
            ],
            gas: 300000000000,
        },
        polygon: {
            url: "RPC_URL",
            accounts: [
                "PRIVATE_KEY",
            ],
        },
        ropsten: {
            url: "https://ropsten.infura.io/v3/",
            accounts: [
                "PRIVATE_KEY",
            ],
        },
        rinkeby: {
            url: "https://eth-rinkeby.nodereal.io/v1/ID",
            accounts: [
                "PRIVATE_KEY",
            ],
            chainId: 4,
            from: "ACCOUNT",
            gas: 300000000000,
        },
        localhost: {
            url: "http://127.0.0.1:8545/",
            accounts: [
                PRIVATE_KEYS
            ],
        },
    },

    etherscan: {
        // Your API key for Etherscan
        // Obtain one at https://etherscan.io/
        apiKey: "API_KEY",
    },

    solidity: "0.8.9",

    settings: {
        optimizer: {
            enabled: true,
            runs: 100,
        },
    },

    mocha: {
        timeout: 40000,
    },
};

:computer: Environment

Using Hardhat 2.11.0

Did you actually replace RPC_URL, PRIVATE_KEY, and API_KEY when you ran it? This looks like an RPC/Hardhat config issue -- do you get the same error if you just run a deploy for any contract?

Yes i get even when i deploy the code

I'd just suggest to check your mumbai network config and RPCs again.

I was able to deploy once and when i try to upgrade or redeploy proxy i am facing the issue

Hi!
Any updates about this issue? I'm experiencing same problems as Nufail.

I have used the Mumbai RPC url: https://rpc-mumbai.matic.today and the Alchemy configuration exactly as is it in the Alchemy configuration.
With different wallets (PRIVATE KEYS). I can deploy one time and then when redeploy or upgrade, have that error written above.
By the way, RPC/Endpoint is working since before anything I get the blocknumber (await ethers.provider.getBlockNumber())
Thanks!

Hi Charly_Fung, I didn't get a solution for this, you can try creating a new upgradeable project and try it from start.

I face the same issue. In my case it might be the contract size, which became too big.

For local deployment using hardhat I already had to use this setting:

allowUnlimitedContractSize: true,

after my contract reached a specific size. From this point on any deployment wasn't possible on Rinkeby and Mumbai. Unfortunately I got no concrete error message. Removing some functions, so that I could deploy also locally without allowUnlimitedContractSize: true, made it work again deploying also on Rinkeby and Mumbai.

2 Likes

Try to set gasLimit of transactions, that was my problem!!

await mintContract.functions.mint(id, amount, {gasLimit: 40000000});

2 Likes

Hi,
did you find a solution for this?

I have the exactly same error messages even on the demo project. I can deploy to local hardhat network but I can't connect to ganache/mumbai

Hi, welcome to the community! :wave:
So have you tried all ways mentioned above?

Hi.
Did anyone find any solution? I am also facing the same problem.

Hi, welcome to the community! :wave:

So what is your config?

I have the same issue I am trying to deploy to goerli

Here is my config:

import * as dotenv from "dotenv"
import { HardhatUserConfig, task } from "hardhat/config"
import "@nomiclabs/hardhat-etherscan"
import "@nomiclabs/hardhat-waffle"
import "hardhat-gas-reporter"
import "solidity-coverage"
import "hardhat-deploy"
import "@nomiclabs/hardhat-ethers"
import "dotenv/config"
import "@typechain/hardhat"

dotenv.config()

const config: HardhatUserConfig = {
  defaultNetwork: "hardhat",
  networks: {
    localhost: {
      chainId: 31337,
      // blockConfirmations: 1,
      allowUnlimitedContractSize: true,
    },
    hardhat: {
      chainId: 31337,
      // blockConfirmations: 1,
      allowUnlimitedContractSize: true,
    },
    rinkeby: {
      chainId: 4,
      // blockConfirmations: 6,
      url: process.env.RINKEBY_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
    },

    goerli: {
      chainId: 5,
      // blockConfirmations: 6,
      url: process.env.GOERLI_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
      allowUnlimitedContractSize: true,
    },
    polygonMumbai: {
      chainId: 80001,
      url: process.env.MUMBAI_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
    },

  },
  solidity: {
    compilers: [{ version: "0.8.4", settings: {
      optimizer: {
        runs: 200,
        enabled: true
      }
    } }, { version: "0.6.12"}],
  },

  mocha: {
    timeout: 300000, // 300 seconds max
  },
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY,
  },

  gasReporter: {
    // enabled: process.env.REPORT_GAS !== undefined,
    enabled: false,
    currency: "INR",
    outputFile: "gas-report.txt",
    noColors: true,
    coinmarketcap: process.env.COINMARKETCAP_API_KEY,
    token: "ETH",
  },

  namedAccounts: {
    deployer: {
      default: 0,
    },
    player: {
      default: 1,
    },
  },
}

export default config

I had the same issue and I figured out that the contract was too big to be deployed. Try reducing the contract size and try again, the contract should be deployed. Tried it in Ethereum Goerli