OpenZeppelin Contracts for ERC20 not deploying in remix IDE - the error I get is Gas estimation errored the transaction execution will likely fail. Returned error: gas required exceeds allowance (125068)

Hi I am not really an expert with solidity. I have been trying to deploy OpenZeppelin Contracts for ERC20 with remix IDE, i have been getting gas estimation error. if I deploy it in testnet it deploys properly with minimal gas but on mainnet using metamask injector provider i get the error. i have tried compiling with different compiler configuration EVM versions like Paris, London and even Berlin but I always get the error.

Below is the simple ECR20 code I am trying to deploy to mainnet.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts@5.0.0/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts@5.0.0/token/ERC20/extensions/ERC20Permit.sol";

contract CoinSeven is ERC20, ERC20Permit {
    constructor() ERC20("Coin", "COIN") ERC20Permit("Coin Seven") {
        _mint(msg.sender, 7777777777777 * 10 ** decimals());
    }
}

Check this answer.

TLDR: Solc Version 0.8.20 has switched the default target EVM version to Shanghai.

Thank you for your response but I am not really an expert the solution you gave is talking about Hardhart but I am trying to deploy with remix. I tried using solidity complier version less than 0.8.20 but the code automatically updates compiler version to match current contract file pragma i.e 0.8.23.

Did you read the TLDR (which I have added right below that linked answer)?

Perhaps this answer helps :slight_smile:

Thanks.. But i still get the error even when i compile with Paris. I don't know what's wrong.

Wow, this is truly astonishing!

What part of "Shanghai" are you having problem understanding?

This is from the answer which was initially given to you:

Are you deploying on bsc????

I am developing on Ethereum mainnet. The error only happens on Ethereum but works on other EVM networks like polygon, BSC e.t.c