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.
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
-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
--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.
--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.