7

What would be the process to map failed transactions (require, throw, etc.) back to the source code line where they occurred?

Any examples of such yet?

8
+50

Something you are looking for is here How to map EVM trace to contract source?. As for me for development purposes I use requireDebugModifier from code below, for production I change requireDebugModifier to requireModifier.

contract DebugEvents
{
    event Debug(string message);

    modifier requireDebugModifier(bool arg, string message)
    {
        if (!arg)
        {
            Debug(message);
            return;
        }
        _;

    }

    modifier requireModifier(bool arg)
    {
        require(arg);
        _;
    }
}

contract Test is DebugEvents
{
    function Test() public payable
    {
    }

    function fooDevel(uint i)
    requireDebugModifier(i<10, "I must be less then 10")
    public
    returns (uint)
    {
        return i;
    }


    function fooProduction(uint i)
    requireModifier(i<10)
    public
    returns (uint)
    {
        return i;
    }

}
  • Unfortunately this method only works if you modify the contract and thus not really answer to the question, because it deals with Solidity Events, not throws. – Mikko Ohtamaa Dec 4 '17 at 10:02
  • However the question you linked is currently the most useful source of information on this topic. As far as I can read the answer "no one has done it publicly." I'll grant you the bounty points any case, so that the good karma does not go unspend :) – Mikko Ohtamaa Dec 4 '17 at 10:03

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.