Solidity: public vs external (in 20 seconds)

Nazreen Mohamad
Nov 19, 2022

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.