Insufficient funds for intrinsic transaction cost

hey everyone , I'm trying to deploy a clone of sushiswap on ropsten , it worked when I deployed it on localhost and all tests worked but when I deploy on ropsten it shows :

C:\Users\mytuf\OneDrive\Desktop\sushiswap>npx hardhat --network ropsten deploy
Nothing to compile
Creating Typechain artifacts in directory types for target ethers-v5
Successfully generated Typechain artifacts!
deploying "UniswapV2Factory"An unexpected error occurred:

Error: ERROR processing C:\Users\mytuf\OneDrive\Desktop\sushiswap\deploy\UniswapV2Factory.js:
Error: insufficient funds for intrinsic transaction cost (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS, version=providers/5.4.4)

this is my hardhat.config.ts file :

// hardhat.config.ts

import "dotenv/config"
import "@nomiclabs/hardhat-etherscan"
import "@nomiclabs/hardhat-solhint"
import "@tenderly/hardhat-tenderly"
import "@nomiclabs/hardhat-waffle"
import "hardhat-abi-exporter"
import "hardhat-deploy"
import "hardhat-deploy-ethers"
import "hardhat-gas-reporter"
import "hardhat-spdx-license-identifier"
import "hardhat-typechain"
import "hardhat-watcher"
import "solidity-coverage"
import "./tasks"

import { HardhatUserConfig } from "hardhat/types"
import { removeConsoleLog } from "hardhat-preprocessor"



const accounts = {
  mnemonic: process.env.MNEMONIC || "test test test test test test test test test test test junk",
  // accountsBalance: "990000000000000000000",
}
const { INFURA_ROPSTEN_RPC_URL, ALCHEMY_ROPSTEN_RPC_URL, PRIVATE_KEY } = process.env;



const config: HardhatUserConfig = {
  abiExporter: {
    path: "./abi",
    clear: false,
    flat: true,
    // only: [],
    // except: []
  },
  defaultNetwork: "hardhat",

  namedAccounts: {
    deployer: {
      default: 0,
    },
    dev: {
      // Default to 1
      default: 1,
      // dev address mainnet
      // 1: "",
    },
  },
  networks: {
    // mainnet: {
    //   url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
    //   accounts,
    //   gasPrice: 120 * 1000000000,
    //   chainId: 1,
    // },
    // localhost: {
    //   live: false,
    //   saveDeployments: true,
    //   tags: ["local"],
    // },
    // hardhat: {
    //   forking: {
    //     enabled: process.env.FORKING === "true",
    //     url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
    //   },
    //   live: false,
    //   saveDeployments: true,
    //   tags: ["test", "local"],
    // },

    hardhat: {
      chainId: 1337,
    },

        ropsten: {
      // url: INFURA_ROPSTEN_RPC_URL,
      url: 'https://ropsten.infura.io/v3/project_id',
      // accounts: [`0x${PRIVATE_KEY}`]
      accounts,
      chainId: 3,
      live: true,
      saveDeployments: true,
      tags: ["staging"],
      gasPrice: 5000000000,
      gasMultiplier: 2,
      
        }
   
  

  },
  paths: {
    artifacts: "artifacts",
    cache: "cache",
    deploy: "deploy",
    deployments: "deployments",
    imports: "imports",
    sources: "contracts",
    tests: "test",
  },
  preprocess: {
    eachLine: removeConsoleLog((bre) => bre.network.name !== "hardhat" && bre.network.name !== "localhost"),
  },
  solidity: {
    compilers: [
      {
        version: "0.6.12",
        settings: {
          optimizer: {
            enabled: true,
            runs: 200,
          },
        },
      },
    ],
  },
  spdxLicenseIdentifier: {
    overwrite: false,
    runOnCompile: true,
  },
  typechain: {
    outDir: "types",
    target: "ethers-v5",
  },
  watcher: {
    compile: {
      tasks: ["compile"],
      files: ["./contracts"],
      verbose: true,
    },
  },
}

export default config

and I have ethers in my ropsten account

For me, the error came up because I was deploying my contract with an eth value greater than what I had in my Metamask wallet. My total wallet balance was 0.9 ETH.
And I was trying to deploy with 1ETH :
var contract = await contractFactory.deploy({value: hre.ethers.utils.parseEther("1")});

changing the value to 0.07 solved it:

var contract = await contractFactory.deploy({value: hre.ethers.utils.parseEther("0.07")});

1 Like

If possible you can share your contract at here, so we can have a check what is wrong?