If your contract emits messages in the reversions, then you can find them out by using debug_traceTransaction
.
NOTE: The debug
RPC module is enabled by default in RSK config, but this is disabled on public nodes.
Furthermore, the RSK public nodes do not expose this feature, and you must run your own node in order to do so.
The following assumes that you have a local node running with RPC exposed on port 4444
.
First, you need to enable debug
module in your config file:
modules = [
...
{
"name": "debug",
"version": "1.0",
"enabled": "true",
},
...
]
Then, you can execute the RPC method passing the
transaction ID as a parameter, like in this example:
curl \
-X POST \
-H "Content-Type:application/json" \
--data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0xa9ae08f01437e32973649cc13f6db44e3ef370cbcd38a6ed69806bd6ea385e49"],"id":1}' \
http://localhost:4444
You will get the following response
(truncated for brevity):
{
...
"result": "08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e536166654d6174683a207375627472616374696f6e206f766572666c6f770000",
"error": "",
"reverted": true,
...
}
Finally, convert result
from hexadecimal to ASCII,
to obtain a readable message:
Ãy SafeMath: subtraction overflow