3

I have heard that the revert reason can be found in the Parity trace. I tried running trace_replayTransaction, and I have found that the output field contains the reason indeed, but there are many other bytes as well, and I can't find their meaning.

Is there a spec for the trace output?

Here's what I get:

 {
        "output": "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000204f6e6c79206f776e65722063616e2075736520746869732066756e6374696f6e",
        "stateDiff": null,
        "trace": [
            {
                "action": {
                    "callType": "call",
                    "from": "0x00bd138abd70e2f00903268f3db08f2d25677c9e",
                    "gas": "0xdd9c8",
                    "input": "...",
                    "to": "0xa38ce7e55bb871f27de73dda17bb002055b45c87",
                    "value": "0x0"
                },
                "error": "Reverted",
                "subtraces": 0,
                "traceAddress": [],
                "type": "call"
            }
        ],
        "vmTrace": null
    }

If I take the tail of the output value starting with 204f.., the decoded value is Only owner can use this function, which is the correct revert reason. What is the meaning of the other bytes, and how do I know where to start cutting off?

  • Can you tell me what the transaction hash is for this trace result? – Thomas Jay Rush Dec 8 '18 at 16:12
  • Sorry, I don't remember. – ulu Dec 9 '18 at 7:56
2

I ended up just ignoring the first part of the output and took the part starting with 204f6e6c... The first byte is the length of the string, the rest is the string itself.

UPDATE: (from the official Solidity docs)

The provided string will be abi-encoded as if it were a call to a function Error(string). In the above example, revert("Not enough Ether provided."); will cause the following hexadecimal data be set as error return data:

0x08c379a0                                                         // Function selector for Error(string)
0x0000000000000000000000000000000000000000000000000000000000000020 // Data offset
0x000000000000000000000000000000000000000000000000000000000000001a // String length
0x4e6f7420656e6f7567682045746865722070726f76696465642e000000000000 // String data
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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