solmate
solmate copied to clipboard
use custom error combined with bytes32 instead of using require with strings
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