1

For example, is slot 0 in this contract the uint256 x or does the custom error take up this slot? Same thing for events.


contract Foo {

error CustomError();
uint256 x;

}

1 Answer 1

0

No, events and errors aren't stored in contract storage like state variables are.

For example take these three contracts:

contract A {
    uint x;
}
contract B {
    error Zero();
    error One();
    error Two();
    error Three();
    error Four();
    error Five();
    error Six();
    error Seven();
    uint x;
}
contract C {
    event Zero();
    event One();
    event Two();
    event Three();
    event Four();
    event Five();
    event Six();
    event Seven();
    uint x;
}

Each contract cost the same amount of gas to deploy:

 gas    77126 gas
transaction cost    67072 gas 
execution cost  12666 gas 

And each contract showed the same size, 0.063 kB, when using forge build --sizes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.