Features of contracts
It is time to delve more deeply into contracts. Let's start with some new features and then we will go deeper into the features we have already seen.
Visibility
The visibility of a state variable or a function defines who can see it. There are four kinds of visibility: external
, public
, internal
, and private
.
By default, the visibility of functions is public
and the visibility of state variables is internal
. Let's see what these visibility functions mean:
external
: External functions can only be called from other contracts or via transactions. For example, we cannot call anf
external function internally:f()
will not work butthis.f()
will. We also cannot applyexternal
visibility to state variables.public
: Public functions and state variables can be accessed in every possible way. Compiler-generated accessor functions are allpublic
state variables. It is not possible to create our own accessors. Actually, it generates only getters, not setters.internal
: Internal functions...