Is it possible to extract logs from reverted transactions in Ganache?

Of course, the public blockchain won't keep logs for reverted transactions.

However, I'm wondering is there a way in ganache (local blockchain) to find out what the logs would have been for a transaction if it hadn't reverted it, that is, the logs that occurred up until the point of reverting?

I am using a ganache fork and simulating some transactions locally and would like to extract such data even for reverted transactions.

2 Answers 2


Yes, you can achieve it by debugging the failed transaction.

From ganache-cli, get the required transaction hash.
In a new terminal window, run npx truffle debug <YOUR_TXN_HASH>
You can then step over to the next line with o, till the point transaction was reverted.

A detailed list of commands is available here: https://trufflesuite.com/docs/truffle/getting-started/using-the-truffle-debugger.html

  • Thank you for your suggestion. I think ; makes more sense, stepping one instruction at a time, and then filtering out any log instructions (I will be doing this programatically). I will try this and see if it works. Feb 23, 2022 at 13:58

Another way would be to use ganache-cli with the verbose flag:


This would log the requests and responses.

Now, after you send your request, you will in the logs the response. This latter would contain the following information:

  "id": 17,
  "jsonrpc": "2.0",
  "result": "...",
  "error": {
    "message": "VM Exception while processing transaction: revert",
    "code": -32000,
    "data": {
      "...": {
        "error": "revert",
        "program_counter": 2145,
        "return": "0x8baa579f"
      "stack": "o: VM Exception while processing transaction: revert\n    at Function.o.fromResults (/app/ganache-core.docker.cli.js:4:297036)\n    at w.processBlock (/app/ganache-core.docker.cli.js:42:106258)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)",
      "name": "o"

The return would contain the revert error.

In this case, it is 0x8baa579f. To know which error is it, you will need to know which encoded function/error signature matches the above.

You can use this online encoder. First, put your ABI there. Then, compare the encoded output with 0x8baa579f.

For more details on how the encoding works, checkout this article.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.