Visibility and access modifiers

As you will notice, each variable is preceded by a visibility specifier (public or internal) that defines the accessibility scope. A public state (storage variable) is visible internally and externally (in this case, Solidity creates an implicit public getter for you). An internal variable, however, is only accessible within the current contract or contracts deriving from it, not by external calls, making it similar to the protected keyword in object-oriented programming languages. By default, variables are internal; therefore, the internal keyword can be omitted. In order to access an internal state, we need to define an explicit public getter function. The following is a getter that we define to read the auction_owner as an internal state (we can define this state as public, and avoid such manipulation):

address internal auction_owner;

function get_owner() view returns(address) {
return auction_owner;
}

Another access modifier, which is unused in our code, is private. This makes the only variable visible within the contract where it is defined, and not in derived contracts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset