error_selector

Returns a custom error's 4-byte selector by hashing already-canonical signature text exactly; use it to identify revert payloads.

Scalar function ABI

Example

Runs locally

SELECT error_selector('ERC20InsufficientBalance(address,uint256,uint256)') AS selector;
-- e450d38c

API reference

error_selector(VARCHAR) #

Hashes one already-canonical custom error signature without normalization.

Inputs

Name Type Use
signature VARCHAR

Signature text such as ERC20InsufficientBalance(address,uint256,uint256), without parameter names or spaces. The text is hashed exactly without normalization.

required positional

Returns

Name Type
selector BYTES4

Custom error selector. First four bytes of the supplied signature's Keccak-256 hash.

Guidance

Selector, topic0, calldata, and return data

Use error_selector or error_selector_json to match revert data selectors before decoding or classifying custom errors. The JSON helper derives canonical input types and ignores parameter names.

  • Canonical signatures omit parameter names and spaces.
  • Use function_selector for calldata selectors.
  • Use event_signature for event topic0.

Runs locally

SELECT error_selector('InsufficientBalance(uint256,uint256)') AS selector;