9

Is there a way that I can print the intermediate result on a console or some log file in order to debug my contract?

1 Answer 1

14

you could use events to debug(log) the desired variable.Please read the official documentation to get more details.

e.g :

 pragma solidity ^0.4.0;

    contract test {
        event test_value(uint256 indexed value1);
        uint256 value_test;

        function test_f()  {

            //value_test processing
            test_value(value_test); // log the current value
        }
    }

an alternative solution is to use the remix (browser solidity) debugger : enter image description here

enter image description here

1
  • 1
    Thanks for being the google to my blockchain adventures <3
    – Ibra
    Commented Aug 26, 2022 at 19:54

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.