Solidity: public vs external (in 20 seconds)

This is a Quick & Simple post on the difference between the public and external modifier in Solidity.

In short, public is for when a function should be callable from outside the contract (by EOAs or other contracts) AND also be callable internally in the contract. external on the other hand is for a narrower use case, for when the function should ONLY be callable from outside, but does not need to be called by other functions inside the contract.

That’s it.

Bonus knowledge: marking a function asexternal saves you a little bit of gas since it does not copy array arguments to memory.

--

--

Technical Instructor and Software Engineer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store