I am trying to run this code but it throws the errors . Is this possible using visibility specifier and constant once ?

pragma solidity ^0.4.0;
contract C {
    function first(uint a) private constant returns (uint b)
        b= a +1;

Yes, you can use multiple modifiers in one function, however, with this code, you will not be able to get the return value from this function because you have made it private.

From the document -

private: Private functions and state variables are only visible for the contract they are defined in and not in derived contracts.

You can make following change in your code and get the return value -

pragma solidity ^0.4.0; 

    contract MyTest { 

        function myfunc(uint a) private returns (uint b) {
            b = a+1;

        function first(uint a) constant returns (uint b) { 
            b = myfunc(a);

Hope this helps.

| improve this answer | |
  • 1
    Thankyou very much , In addition :- internal, external can be accessed directly with using constant ?. I failed to do that . – Gopal ojha Jun 22 '17 at 9:37
  • Post the code, will help you out. – Sanchit Jun 22 '17 at 18:46

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.