Search code examples
ethereumsolidityweb3js

Modifiers in solidity placement


Can

_;

be surrounded by other code? for example:

modifier foo {
    require(msg.value > 100, "Boo");
    _;
    globVar = 1010;
}

I am watching a tutorial, so I am not set up for tests.


Solution

  • It can.

    Code before the underscore gets executed before the function (that uses this modifier) - and code after the underscore is executed after the function.