error_selector_json

Returns the 4-byte selector for a custom error described by JSON ABI; use it to identify revert payloads.

Example

Local

1
SELECT error_selector_json(json('{
2
"type": "error",
3
"name": "ERC20InsufficientBalance",
4
"inputs": [
5
{"name": "sender", "type": "address"},
6
{"name": "balance", "type": "uint256"},
7
{"name": "needed", "type": "uint256"}
8
]
9
}')) AS selector;
10
-- e450d38c
Notebook ready in readonly mode.

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

error_selector_json(JSON) #

Builds the canonical custom error signature from JSON ABI inputs before hashing with Keccak-256.

Inputs

Name Type Use
abi JSON

A single custom error ABI object with name and inputs.

required positional

Returns

Name Type
selector BYTES4

Custom error selector. First four bytes of the canonical error 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.

Local SQL

1
SELECT error_selector('InsufficientBalance(uint256,uint256)') AS selector;
Notebook ready in readonly mode.

Related functions

Category and tags

Tag
ABI