April 2017
Intermediate to advanced
266 pages
7h 4m
English
We saw earlier what a function modifier is, and we wrote a basic function modifier. Now let's look at modifiers in depth.
Modifiers are inherited by child contracts, and child contracts can override them. Multiple modifiers can be applied to a function by specifying them in a whitespace-separated list and will be evaluated in order. You can also pass arguments to modifiers.
Inside the modifier, the next modifier body or function body, whichever comes next, is inserted where _; appears.
Let's take a look at a complex code example of function modifiers:
contract sample { int a = 90; modifier myModifier1(int b) { int c = b; _; c = a; a = 8; } modifier myModifier2 { int c = a; _; } modifier myModifier3 { a = 96; ...