Is it possible for me to call from a contract B, that has an instance of A, a private or internal function of contract A?


No, you cannot call a private or internal function in another contract.

  • private: only visible in the current contract
  • internal: only visible internally


Private functions can only be called from the same contract, whereas internal functions can be called from the same contract, as well as contracts inheriting from that contract. They are usually private or internal for a reason. If it's your own contract, you can create a public function in contract A, that you can call from B.

  • "internal: only visible internally" won't mean anything to anyone who doesn't already know what internal is and what exactly it is used for. – goodvibration Aug 5 '20 at 13:41
  • You're right. I added a brief explanation to explain the difference. – Morten Aug 5 '20 at 13:45
  • You could simply just use the same pattern you've used for the first bullet (e.g., "internal: visible in the current contract as well as every inheriting contract"). – goodvibration Aug 5 '20 at 13:56
  • This is quoted from the Solidity documentation directly. – Morten Aug 5 '20 at 14: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.