Compile error: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for

Hi, im having problems compiling:

Compiling ./src/contracts/Colors.sol...
Compiling ./src/contracts/ERC721Full.sol...
Compiling ./src/contracts/Migrations.sol...
Compiling @openzeppelin/contracts/GSN/Context.sol...
Compiling @openzeppelin/contracts/drafts/Counters.sol...
Compiling @openzeppelin/contracts/introspection/ERC165.sol...
Compiling @openzeppelin/contracts/introspection/IERC165.sol...
Compiling @openzeppelin/contracts/math/SafeMath.sol...
Compiling @openzeppelin/contracts/token/ERC721/ERC721.sol...
Compiling @openzeppelin/contracts/token/ERC721/ERC721Enumerable.sol...
Compiling @openzeppelin/contracts/token/ERC721/ERC721Full.sol...
Compiling @openzeppelin/contracts/token/ERC721/ERC721Metadata.sol...
Compiling @openzeppelin/contracts/token/ERC721/IERC721.sol...
Compiling @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol...
Compiling @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol...
Compiling @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol...
Compiling @openzeppelin/contracts/utils/Address.sol...

Compilation warnings encountered:

@openzeppelin/contracts/utils/Address.sol:31:32: Warning: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for. It will be interpreted as an invalid instruction on this VM.
        assembly { codehash := extcodehash(account) }
                               ^------------------^
,/Users/roberto/Development/blockchain/ERC721/nft/src/contracts/ERC721Full.sol:330:32: Warning: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for. It will be interpreted as an invalid instruction on this VM.
        assembly { codehash := extcodehash(account) }
                               ^------------------^


@openzeppelin/contracts/utils/Address.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.5;
^---------------------^
,/Users/roberto/Development/blockchain/ERC721/nft/src/contracts/Colors.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.5;
^---------------------^
,/Users/roberto/Development/blockchain/ERC721/nft/src/contracts/ERC721Full.sol:300:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.5;
^---------------------^
,@openzeppelin/contracts/utils/Address.sol:31:32: Warning: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for. It will be interpreted as an invalid instruction on this VM.
        assembly { codehash := extcodehash(account) }
                               ^------------------^
,/Users/roberto/Development/blockchain/ERC721/nft/src/contracts/ERC721Full.sol:330:32: Warning: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for. It will be interpreted as an invalid instruction on this VM.
        assembly { codehash := extcodehash(account) }
                               ^------------------^
Compilation failed. See above.
Truffle v5.0.5 (core: 5.0.5)
Node v15.5.1`

my contract:

pragma solidity ^0.5.5;
import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol";
// solo se  deja este de abajo porque es  un tutorial
//import "./ERC721Full.sol";

contract  Color is ERC721Full {

    constructor() ERC721Full("Color", "COLOR") public {
    }
}

Let me know if you need more information, thanks!

1 Like

I think just like the prompt said:

SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.5;

you should use a higher compile version, maybe your config should be:

module.exports = {
  solidity: {
    version: "0.5.12",
    // settings: {
    //   optimizer: {
    //     enabled: true,
    //     runs: 200,
    //   },
    // },
  },
}

As for why I think you should 0.5.12, cause there is a warning:

Warning: The “extcodehash” instruction is not supported by the VM version “byzantium” you are currently compiling for

I am not which compile version can solve this warning, maybe 0.5.10 or 0.5.11, but 0.5.12 must can deal with this warning.

1 Like

Hi @robertocohan,

Welcome to the community :wave:

Adding to @skyge’s response.

You may also want to look at using the latest version of OpenZeppelin Contracts, 3.4:


As an aside, please see how to Format code in the forum.