Solidity Variables – Understanding the Public Keyword for a Variable

solidity

Example:

address public owner;

Also, if we don't make a variable public manually, what is the default, private?

Best Answer

See https://programtheblockchain.com/posts/2018/01/02/making-smart-contracts-with-public-variables/ for a full explanation.

Yes, the default visibility for state variables is internal(as per v0.8.4). Marking it public makes it easy to read the variable in a DApp or from another smart contract.

Related Topic