Can External functions call the internal functions, private functions and the public function of the same contract in their body in Solidity?

  • 2
    Yes (they would be almost useless otherwise). – goodvibration Jul 11 '18 at 4:46

Yes. The external modifier only changes how the function itself may be called, it does not affect the execution of the function with respect to calling other methods.


Yes you can as long as those functions does not change the state of the contract. Completely for get purposes only.

  • Everything after the first word in this answer is wrong! – goodvibration Jul 11 '18 at 4:54
  • @goodvibration Saying this is wrong without an argument is much more wrong. Whilst in my opinion this has a valid point – keysl Jul 11 '18 at 4:57
  • @keysl: It's just wrong. Not a lot more to say. The visibility of a function (private / internal / external / public) and the mutability of a function (pure / view / neither) are two independent characteristics. The only argument to defend it with is that an external function can only call private/internal/public functions of the same mutability level or "lower" (e.g., view can call only view and pure, pure can call only pure, etc). But this argument is a very weak defense-line, since the question is not about mutability levels. – goodvibration Jul 11 '18 at 5:03
  • @goodvibration I'm sorry if it caused a misunderstanding. But what I intend to say with for viewing purposes only is to display or just get something, I was not talking about mutability. Hence, I edited my post to hopefully make it less confusing. If you still find it wrong, please, feel free to correct me. I would highly appriciate that. – vhie Jul 11 '18 at 6:20
  • You haven't changed anything (except "view" to "get"). The answer is still wrong. A non-constant external function can call non-constant internal/private/public functions (which DO change the state of the contract). – goodvibration Jul 11 '18 at 6:22

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.