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

up vote 9 down vote accepted

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

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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