6

Example:

address public owner;

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

1 Answer 1

7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.