Skip to content

Instantly share code, notes, and snippets.

@DonkeVerse
Created March 5, 2022 09:41
Show Gist options
  • Save DonkeVerse/fb8af697ae1e9057e0d47cb4dc7b199a to your computer and use it in GitHub Desktop.
Save DonkeVerse/fb8af697ae1e9057e0d47cb4dc7b199a to your computer and use it in GitHub Desktop.

You can paste this code into remix to verify these results

// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.11;

contract RevertRequire {
    error TestError();

    // optimization set to 10,000
    function testRevertRequire(uint256 number) external pure {
        if (number < 10) revert TestError();  // 21,464 gas success, 21,431 gas fail
        require(number < 10, "Test Error");   // 21,428 gas success, 21,515 gas fail
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment