Problem The transaction fails because the transaction ran out of gas instead of it failing because the require condition was not met. It works fine before the solidity update to version 0.4.24. It works in all environment. It can even return the reason I provided with the error in the require parameter. Why is it saying that the gas is not enough? I've tried to assign a higher gas limit, higher than 3000000. I am using remix.ide

Note Everything works fine if I don't make the require onlyOwner modifier to result to an error.

Expected result Error with provided reason Contract Code

pragma solidity ^0.4.24;

 contract Owned {
 address public owner;
 address public newOwner;

 event OwnershipTransferred(address indexed _from, address indexed _to);

 constructor() public {
     owner = msg.sender;

 modifier onlyOwner {
     require(msg.sender == owner);

 function transferOwnership(address _newOwner) public onlyOwner {
     newOwner = _newOwner;

 function acceptOwnership() public {
     require(msg.sender == newOwner);
     emit OwnershipTransferred(owner, newOwner);
     owner = newOwner;
     newOwner = address(0);

Using JavaScript VM Environment expected result even on Injected Web3 and Web3 Provider Environment

-The image above is the result I expect to get when I use the Injected Web3 and Web3 Provider Environment as that is how it works before around the solidity version 0.4.23.

Using Injected Web3 and Web3 Provider Environment Occurs upon execution of transferOwnership()

--The window on the above image will pop-up upon execution of the transferOwnership() function. The function with the onlyOwner modifier which require the msg.sender to be equal to the contract owner.

After I force execute the transaction of transferOwnership()

--The image is the result when I choose to still proceed with the transaction even after the warning from the 2nd Image. It results to the same "Transaction mined but execution failed" status like when I ran it using the JavaScriptVM Environment but without the "VM error: revert." return.

3 Answers 3


As per your code, the owner of your contract is the Account Address with which you deploy the contract on the network:

constructor() public { owner = msg.sender; ////For eg. 0xca35b7d915458ef540ade6068dfe2f44e8fa733c -> JS VM }

Now since the transferOwnership() function call uses the modifier "onlyOwner", it mandates msg.sender for this transaction should be same as the deployer of the contract.

Hope it helps!!


@vhie I tried you code and works fine on Remix, I think the problem is that you are selecting the wrong account for each operation so it triggers the require and do a revert.

You have to make sure that you are selecting the newOwner address for the acceptOwnership() function and the owner address on the transferOwnership() function.

If I select the wrong address in either of these functions I get the same error as you.

  • Hi, I'm sorry but that is exactly my problem. The gas error when I trigger the require condition. I will edit my question to note this. It is not suppose to return that error. Like I said above it is suppose to return the same error as the one in Image 1 or 2. If I execute the function correctly meaning not triggering the require condition to revert it works fine. The problem it when I do trigger the require function to error and revert. Thank you
    – vhie
    Commented Jul 5, 2018 at 1:37
  • 1
    I see @vhie sorry I didn't understand your question. Apparently this was added to remix but for some reason is not displaying it anymore. github.com/ethereum/remix/pull/760 maybe you can open a issue. Commented Jul 5, 2018 at 16:51
  • 1
    I see, Thank you for the information. Could this be the reason why it only works in the JavaScript VM Environment and not in Web3 Provider or Injected Web3 Environment?
    – vhie
    Commented Jul 6, 2018 at 1:29
  • Hi, this pull request github.com/ethereum/remix/pull/760 add the ability to display the reason of the REVERT for the JavaScript VM. It is not possible for now to display the REVERT reason for other environment.
    – Yann
    Commented Jul 6, 2018 at 9:50
  • For me, I had the wrong contract address that I was connecting to.
    – Kirby
    Commented Nov 4, 2018 at 23:08

The fact that it gives the error Note: The constructor should be payable if you send value. is a bug. It obviously shouldn't give that error since you're not even executing a constructor when calling transferOwnership.

Misc extra info: Prior to the Byzantium hard fork, there was no REVERT opcode. If a require failed, it would always consume all the gas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.