Skip to content

hardhat template to compare various error gas cost in solidity

Notifications You must be signed in to change notification settings

drgorillamd/error-gas-test

Repository files navigation

Custom errors vs require: gas cost

usage

yarn install
yarn test

To add another error type

Copy one of the contracts in ./contracts and add your template (make sure to ONLY include a custom error/revert, keeping the rest of the contract identical in order to proceed to an apple-to-apple comparison + use the gasLimit override to bypass the (failing) gas estimation from ethers)

Results:

Summary (each test write one uint in storage, reflected in the successful transaction cost):

┌──────────────────────┬────────────┬─────────┬─────────┐
│       (index)        │ deployment │ failed  │ success │
├──────────────────────┼────────────┼─────────┼─────────┤
│    errorLongName     │  '86445'   │ '21483' │ '43562' │
│     errorOneArg      │  '88179'   │ '21501' │ '43562' │
│   errorOneNamedArg   │  '88179'   │ '21501' │ '43562' │
│    errorOneString    │  '97557'   │ '21537' │ '43562' │
│    errorThreeArgs    │  '91635'   │ '21537' │ '43562' │
│     errorTwoArgs     │  '89691'   │ '21519' │ '43562' │
│   errorWithoutArgs   │  '86445'   │ '21483' │ '43562' │
│  requireWithString   │  '97161'   │ '21537' │ '43562' │
│ requireWithoutString │  '82113'   │ '21438' │ '43562' │
└──────────────────────┴────────────┴─────────┴─────────┘

About

hardhat template to compare various error gas cost in solidity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published