Skip to content

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

Description

@malik672
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions