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

Hello everyone,

I am making my first small dapp with erc721, and I am facing this error on Remix IDE:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol:29: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) }

I am importing ERC721Full.sol and Ownable.sol from openzeppelin github. Is it a big deal? If so, how could I solve it?


Welcome to the community @vortextemporum :wave:

I assume that you are importing OpenZeppelin Contracts from the master branch and you are using Compiler version 0.5.1.

You should only use code published in an official release of OpenZeppelin Contracts, the latest release is 2.3. When importing via GitHub on Remix you can specify the release tag, (otherwise you will get the latest code in the master branch). The example GameItem.sol below imports v2.3.0.

Compiler 0.5.1 has a default EVM version of byzantium whilst Compiler 0.5.11 has a default EVM version of petersburg. You may also want to use Compiler version 0.5.11.

Alternatively to using Remix, have a look at the Getting Started guide for information on how to setup a development environment.


Imports OpenZeppelin Contracts 2.3.

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/token/ERC721/ERC721Full.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.3.0/contracts/drafts/Counters.sol";

contract GameItem is ERC721Full {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721Full("GameItem", "ITM") public {

    function awardItem(address player, string memory tokenURI) public returns (uint256) {

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;

Thanks, confirming this works in Remix with compiler version 0.5.11 and EVM version petersburg.

1 Like

Thank you a lot! This solved the problem. As you guessed, I was importing from the master branch. And importing from 2.3 solved.

1 Like

Hi @vortextemporum
Great to hear that it is working for you now.

If you get a chance it would be great to hear about the app that you are working on.

Created an Issue to update the pragma version: https://github.com/OpenZeppelin/openzeppelin-contracts/issues/1897