Glossary
Custom Error
A Solidity feature (since 0.8.4) that lets contracts revert with a typed, ABI-encoded error instead of an expensive string — cheaper to emit and to decode.
Before 0.8.4, reverts carried a string ("ERC20: transfer amount
exceeds balance") that consumed real calldata and storage. Custom
errors define typed structures —
error InsufficientBalance(uint256 available, uint256 required) —
that revert with the four-byte error selector plus ABI-encoded
arguments.
Gas costs drop significantly compared to string reverts, and clients can decode the error structurally rather than parsing a message. Modern contract libraries (OpenZeppelin 5.0, Solady) use custom errors throughout.