There are four types of function visibility in Solidity:
external
, internal
, private
, and public
.
Private | Internal | Public | External |
Accessible only within the contract | Accessible only within the contract and contracts deriving from this contract | Accessible by everyone | Accessible only by other contracts and external services |
private
modifier specifies that this function is accessible only within your contract. Cannot be called from outside the contract or even by children inheriting the contract. This is the most restrictive visibility.
internal
modifier specifies that only the contract and its children (through inheritance) can access this function.
public
modifier means that everyone can access this function. Unless otherwise specified, all functions are made public by default.
external
modifier means that only other contracts and services outside the contract can all this function. This function cannot be called from within the same contract. Must be called externally.