Skip to content

eth: add official revert error code for call methods#600

Merged
fjl merged 1 commit into
ethereum:mainfrom
fjl:eth-revert-error
Oct 14, 2025
Merged

eth: add official revert error code for call methods#600
fjl merged 1 commit into
ethereum:mainfrom
fjl:eth-revert-error

Conversation

@fjl

@fjl fjl commented Oct 24, 2024

Copy link
Copy Markdown
Contributor

Here I am trying to add an official way of getting the revert data of a contract call. This is often requested by users:

The spec I'm adding here is what geth has been doing since 2022. It seems best to assign a separate error code because it's an unambiguous way of telling the error.

Comment thread src/eth/execute.yaml
schema:
$ref: '#/components/schemas/bytes'
errors:
- code: 3

@ahamlat ahamlat Oct 24, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to have an error code similar to what we have on the engine API :

| -32700 | Parse error | Invalid JSON was received by the server. |

Choose a close number like -31000

@fjl fjl Oct 28, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using code 3 here because it is the error code used by geth and erigon for this condition.

There is no requirement for codes to be negative - the JSON-RPC spec says "The error codes from and including -32768 to -32000 are reserved for pre-defined errors. ... The remainder of the space is available for application defined errors."

@fjl

fjl commented Jan 27, 2025

Copy link
Copy Markdown
Contributor Author

I recently discovered MetaMask implements this spec change already.

@kclowes kclowes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, this looks good to me. Would be nice to have this standardized across clients!

@fjl fjl merged commit c138ce0 into ethereum:main Oct 14, 2025
@fjl

fjl commented Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

Merged after consensus was found in RPC Standards Call 14 ethereum/pm#1758

@mrzeszutko

mrzeszutko commented Oct 15, 2025

Copy link
Copy Markdown

@fjl the standard defines the same response for the following endpoints:

  • eth_call
  • eth_estimateGas
  • eth_createAccessList
errors:
    - code: 3
      message: "execution reverted"
      data:
        title: "raw EVM revert data"
        $ref: "#/components/schemas/bytes"

-- edited ---

eth_createAccessList does not return error codes - can we make it consistent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants