Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use custom error combined with bytes32 instead of using require with strings #392

Open
malik672 opened this issue Oct 3, 2023 · 0 comments

Comments

@malik672
Copy link

malik672 commented Oct 3, 2023

contract test {//deployment cost: 109638 in gas cost
    error notEqual(bytes32);
     function red(uint a) public pure {//224 in gas cost if successful and 287 if it reverts
        if(a != 20){
          revert notEqual(bytes32("authorized"));
        }
    }
}

contract test1 {//deployment cost: 113364 in gas cost
    function red(uint a) public pure {//224 in gas cost if successful and 323 if it reverts
        require(a == 20, "unauthorized");
    }
}

i've not tested this with the code base , the total loc of the codebase are way too much and takes too much time to compile on my computer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant