Writing a Function to Read the Target Number
Writing a Function Read the Target Number#
Now that we have a function that allows users to play the Money Game, let's create a function that actually allows the
owner of the MoneyGame to read the
targetNumber. This function will be created to introduce the notion of creating function
modifiers and applying them to the functions that we create.
modifier creates additional features (or alternatively restrictions) on a function. To declare a
modifier, after you write your modifier, add a
_; to the function Source.
We will call our modifier onlyOwner. The code in the modifier will run on functions that use the modifier. In our case, this will ensure that the person calling a function is the manager set in the smart contract. We will also add
_; to the modifier so that the compiler knows that we are creating a modifier.