Visibility
Solidity provides four different types of visibility specifiers to help us control access to functions and variables.
Functions can be marked as public
, private
, internal
, or external
.
Variables can be marked as public
, private
, or internal
.
public
: Can be called by any contract or off-chain entity.private
: Can only be called from within the main contract.internal
: Can be called from within the main contract or a child contract.external
: Can be called from other contracts that do not inherit from the main contract, or any other off-chain entities.