Ethereum-Solidity Quiz Q17: What visibility modifiers does Solidity use?

Published: (January 10, 2026 at 06:34 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Visibility Modifiers Overview

ModifierWithin ContractDerived ContractOther ContractExternal
public
internal
private
external❌ (via this)

Solidity uses four visibility modifiers to control how functions and state variables can be accessed:

  • public – can be called from within the contract, other contracts, and externally.
  • external – can be called from other contracts and externally; not from within the same contract (except via this).
  • internal – can be called from within the same contract and derived contracts (inheritance); not from other contracts or externally.
  • private – can be called only from within the same contract; not from derived contracts, other contracts, or externally.

Important notes

  • State variables can be public, internal, or private (they cannot be external).
  • Functions can be public, internal, private, or external.
  • public state variables automatically generate getter functions.
  • external functions are more gas‑efficient than public because they don’t create an internal function copy.
  • private and internal do not provide security; blockchain data is always visible, they only restrict access via function calls.
  • Use external for functions intended to be called from outside the contract.
  • Use internal for helper functions used through inheritance.
  • Use private with caution—typically only for internal helper functions.
  • Use public for state variables that need to be publicly accessible.
  • Remember that private provides no security; it merely prevents accidental calls.
Back to Blog

Related posts

Read more »