Skip to content

Instantly share code, notes, and snippets.

@mishfit
Last active February 9, 2018 00:32
Show Gist options
  • Save mishfit/7b75f82dd18f9fed816d01481c0eb3ee to your computer and use it in GitHub Desktop.
Save mishfit/7b75f82dd18f9fed816d01481c0eb3ee to your computer and use it in GitHub Desktop.
Revert Costs Less Than Require
pragma solidity ^0.4.19;
contract CompareAssertions {
function requireExample (uint256 input) public pure returns (uint256) {
require(input > 5);
uint256 result = 5 * input;
require(result > input);
return result;
}
function revertExample (uint256 input) public pure returns (uint256) {
uint256 result;
if (input < 5 || ((result = 5 * input) < input)) revert();
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment