August 2019
Intermediate to advanced
486 pages
13h 52m
English
A function can be a view function when it is not modifying any state variables of the contract. The compiler also throws a warning message during compilation in order to convert a function into a view function if it is not modifying any state variables. You should resolve those warnings and use the view modifier for the functions indicated by the compiler warning; this would reduce gas consumption and data would be returned instantly. The view functions are mainly used to return the current state of the contract.
The following code is getting the current state of the exchange:
contract ViewFuncExample { enum ExchangeStatus { Inactive, Active } ExchangeStatus status = ExchangeStatus.Active;