REMIX IDE - bsc testnet - ERROR: invalid opcode: PUSH0 OR EVM version used by the selected environment is not compatible with the compiler EVM version

I have changed my ERC721 contracts to the new version v0.8.20.

When trying to deploy to the BSC-Testnet network I get the following error:

invalid opcode: PUSH0
OR the EVM version used by the selected environment is not compatible with the compiler EVM version.

First time I have had an error of this kind. Any idea what it could be?

2 Likes

Solidity version 0.8.20 is not supported on BSC. Use 0.8.19

Or in the advanced compiler settings, change the EVM version to one that is supported by your chain.

Thank you. I have tried the london version and it also works.
Do you know how to configure this in Hardhat?

In Hardhat, set evmVersion in the Hardhat config. See https://hardhat.org/hardhat-runner/docs/guides/compile-contracts#configuring-the-compiler

like this?:

optimizer: {
        enabled: true,
        runs: 1000,
      },
evmVersion: {
 version : "london"
},

like this:

optimizer: {
        enabled: true,
        runs: 1000,
      },
evmVersion: "london",
1 Like

Will it work on BSC Mainnet or do i need to lower the compiler version there also. Even I faced the same issue

Let's hope so because otherwise we will have a big problem.

I tried on mainnet.
{Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Returned error: invalid opcode: opcode 0x5f not defined
OR the EVM version used by the selected environment is not compatible with the compiler EVM version. }

Faced the same issue .

Can you try from your end ?

I was using the solidity version above 20 for ERC721 contract

If you launch from remix, try selecting a different compiled version in advanted configuration:
See the image and select it there:

london works for me in testnet but you can try with paris more new.

If you use hardhat, put the same in it configuration file.

I won't be attacking mainnet for a few weeks and I can't tell you if it works for me.

thanks.

what was your compiler version?

london works for me in testnet.

Hello every one
I got this error on calling a function on my new smart contract:

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Returned error: invalid opcode: MCOPY
OR the EVM version used by the selected environment is not compatible with the compiler EVM version.

This function was working on the same contract, the only change is that the contract is redeployed and now it's not working!

This error seems to indicate that there is a discrepancy between the version of the Ethereum Virtual Machine (EVM) for which the smart contract was compiled and the version of the EVM that is being used in the environment where you are trying to execute the contract function.

The "MCOPY" message indicates that an attempt is being made to copy memory in a way that is not compatible with the EVM version.