error_decode_json

Returns a status-rich JSON description of EVM revert bytes; supply an ABI to decode matching custom errors.

Example

Local

1
SELECT error_decode_json(
2
error_selector('Panic(uint256)')::BYTES || evm_abi_word(17::UINT256)::BYTES
3
) AS diagnostic;
4
-- diagnostic.decode_status = decoded
Notebook ready in readonly mode.

API reference

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

error_decode_json(BYTES) # Builtin Or Raw Error Diagnostic

Decodes raw revert bytes without an ABI registry lookup.

Inputs

Name Type Use
revert_data BYTES

Raw revert bytes returned by a failed eth_call or simulated execution.

required positional

Returns

Name Type
diagnostic JSON

Revert diagnostic JSON. Fields by decode_status: decoded has selector, signature, name, and args; unknown has selector (possibly null), raw, and payload_words; ambiguous has selector; decode_error has error, raw, and selector when available.

Guidance

Inspect failed calls

Use error_decode_json when a read, preflight, or local execution returns revert bytes and you need a reviewable row explaining the failure. Required NULL inputs propagate NULL.

  • Use the ABI overload when you already have the contract ABI.
  • Use evm_decode_revert_for when the ABI has been registered for a chain/address/block context.
  • A decoded registry-backed custom error adds abi_label when the selected registration has a label.
  • Keep the raw revert bytes in evidence rows when the decoded name is not enough for review.

Additional overloads

error_decode_json(JSON, BYTES) # Abi Error Diagnostic

Decodes revert bytes with JSON ABI error definitions.

Inputs

Name Type Use
abi JSON

Contract ABI JSON containing error definitions.

required positional
revert_data BYTES

Raw revert bytes returned by a failed call.

required positional

Returns

Name Type
diagnostic JSON

Revert diagnostic JSON. Fields by decode_status: decoded has selector, signature, name, and args; unknown has selector (possibly null), raw, and payload_words; ambiguous has selector; decode_error has error, raw, and selector when available.

Overload examples

Local SQL

1
SELECT error_decode_json(
2
'[{"type":"error","name":"ERC20InsufficientBalance","inputs":[{"name":"sender","type":"address"},{"name":"balance","type":"uint256"},{"name":"needed","type":"uint256"}]}]'::JSON,
3
error_selector('ERC20InsufficientBalance(address,uint256,uint256)')::BYTES
4
|| evm_abi_word('0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472'::ADDRESS)::BYTES
5
|| evm_abi_word(500000000::UINT256)::BYTES
6
|| evm_abi_word(615568393::UINT256)::BYTES
7
) AS diagnostic;
8
-- diagnostic.name = ERC20InsufficientBalance
error_decode_json(VARCHAR, BYTES) # Abi Error Diagnostic

Decodes revert bytes with VARCHAR ABI error definitions.

Inputs

Name Type Use
abi VARCHAR

Contract ABI JSON containing error definitions.

required positional
revert_data BYTES

Raw revert bytes returned by a failed call.

required positional

Returns

Name Type
diagnostic JSON

Revert diagnostic JSON. Fields by decode_status: decoded has selector, signature, name, and args; unknown has selector (possibly null), raw, and payload_words; ambiguous has selector; decode_error has error, raw, and selector when available.

Overload examples

Local SQL

1
SELECT error_decode_json(
2
'[{"type":"error","name":"ERC20InsufficientBalance","inputs":[{"name":"sender","type":"address"},{"name":"balance","type":"uint256"},{"name":"needed","type":"uint256"}]}]'::VARCHAR,
3
error_selector('ERC20InsufficientBalance(address,uint256,uint256)')::BYTES
4
|| evm_abi_word('0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472'::ADDRESS)::BYTES
5
|| evm_abi_word(500000000::UINT256)::BYTES
6
|| evm_abi_word(615568393::UINT256)::BYTES
7
) AS diagnostic;
8
-- diagnostic.name = ERC20InsufficientBalance

Related functions

Category and tags

Tag
ABI