Functions and state variables can have visibility modifiers. There are four visibility modifiers in solidity. Functions can be specified as public, private, internal, or external. State variables support all visibility levels except external. In this recipe, you will learn about visibility modifiers and how to use them.
Using visibility modifiers efficiently
How to do it...
-
If you want the function to be accessible both externally and internally, it has to be marked as public. Public state variables will generate a getter function automatically:
pragma solidity ^0.4.21;
contract Visibility {
// Public state variables generate an automatic getter
uint public limit = 110021;
// Accessible externally and internally...