Revert contexts
A revert context marks an instruction associated with a function revert. It extends the function identity schema with an optional pointer to revert reason data and/or a numeric panic code for built-in assertion failures.
- Explore
- View source
- Playground
- YAML
- JSON
$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "schema:ethdebug/format/program/context/function/revert"
title: ethdebug/format/program/context/function/revert
description: |
This context indicates that the marked instruction is
associated with a function revert. Extends the function
identity schema with an optional pointer to revert reason
data and/or a numeric panic code.
type: object
properties:
revert:
type: object
$ref: "schema:ethdebug/format/program/context/function"
properties:
reason:
type: object
title: Revert reason
description: |
Pointer to the revert reason data. This typically contains
an ABI-encoded error message or custom error data.
properties:
pointer:
$ref: "schema:ethdebug/format/pointer"
required:
- pointer
panic:
type: integer
title: Panic code
description: |
Numeric panic code for built-in assertion failures.
Languages may define their own panic code conventions
(e.g., Solidity uses codes like 0x11 for arithmetic
overflow).
unevaluatedProperties: false
required:
- revert
examples:
# -----------------------------------------------------------
# Revert with reason: require() failure in transfer
# -----------------------------------------------------------
# This context would mark the REVERT instruction after a
# failed require(). The compiler has written the ABI-encoded
# Error(string) revert reason into memory:
#
# 0x80..0xe3: ABI-encoded Error(string) (100 bytes)
# selector 0x08c379a0 + offset + length + data
- revert:
identifier: "transfer"
reason:
pointer:
location: memory
offset: "0x80"
length: "0x64"
# -----------------------------------------------------------
# Panic: arithmetic overflow (code 0x11)
# -----------------------------------------------------------
# A built-in safety check detected an arithmetic overflow.
# The panic code alone identifies the failure; no pointer to
# revert data is needed since the compiler inserts the check
# itself.
- revert:
panic: 17
# -----------------------------------------------------------
# External call revert: processing a failed CALL
# -----------------------------------------------------------
# This context would mark an instruction after a CALL that
# reverted. The callee's revert reason is accessible via the
# returndata buffer:
#
# returndata 0x00..0x63: ABI-encoded revert reason
- revert:
reason:
pointer:
location: returndata
offset: 0
length: "0x64"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "schema:ethdebug/format/program/context/function/revert",
"title": "ethdebug/format/program/context/function/revert",
"description": "This context indicates that the marked instruction is\nassociated with a function revert. Extends the function\nidentity schema with an optional pointer to revert reason\ndata and/or a numeric panic code.\n",
"type": "object",
"properties": {
"revert": {
"type": "object",
"$ref": "schema:ethdebug/format/program/context/function",
"properties": {
"reason": {
"type": "object",
"title": "Revert reason",
"description": "Pointer to the revert reason data. This typically contains\nan ABI-encoded error message or custom error data.\n",
"properties": {
"pointer": {
"$ref": "schema:ethdebug/format/pointer"
}
},
"required": [
"pointer"
]
},
"panic": {
"type": "integer",
"title": "Panic code",
"description": "Numeric panic code for built-in assertion failures.\nLanguages may define their own panic code conventions\n(e.g., Solidity uses codes like 0x11 for arithmetic\noverflow).\n"
}
},
"unevaluatedProperties": false
}
},
"required": [
"revert"
],
"examples": [
{
"revert": {
"identifier": "transfer",
"reason": {
"pointer": {
"location": "memory",
"offset": "0x80",
"length": "0x64"
}
}
}
},
{
"revert": {
"panic": 17
}
},
{
"revert": {
"reason": {
"pointer": {
"location": "returndata",
"offset": 0,
"length": "0x64"
}
}
}
}
]
}
Reason-based revert
The reason field contains a pointer to the revert reason data
in memory or, for external calls, in the returndata buffer.
This typically holds an ABI-encoded error: a require() failure
produces an Error(string) payload, while custom errors produce
their own ABI-encoded selector and arguments.
For an internal revert, reason points into memory where the
compiler has written the encoded error. For an external call
that reverted, reason points into the returndata buffer
containing the callee's revert output.
Panic codes
The panic field carries a numeric code for built-in assertion
failures that the compiler inserts automatically. These do not
originate from explicit revert or require statements—they
guard against conditions like arithmetic overflow or
out-of-bounds array access.
Languages define their own panic code conventions. For example,
Solidity uses 0x01 for failed assert(), 0x11 for
arithmetic overflow, and 0x32 for out-of-bounds indexing.
A revert context may include panic alone (when no reason
pointer is needed), reason alone, or both.
Field optionality
Both reason and panic are optional. A revert context is
valid with either, both, or neither—a bare revert: {} is
permitted when the compiler knows a revert occurred but has no
further detail.
Function identity fields (identifier, declaration, type)
are also optional. A compiler may omit them when the revert
cannot be attributed to a specific function, such as a
top-level require guard or an unattributed external call
failure.