Another way would be to use ganache-cli
with the verbose flag:
--verbose
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.