In a contract where a modifier like this would be reused a lot, is ID inherited by the function that uses the modifier? If not, this check would need to be in the function. If yes, is there any drawbacks from putting uint ID in the modifier?

modifier isMember (address _foo) {
  uint ID = memberIndex[_foo];
  require(ID != 0); 

1 Answer 1


No, a function cannot access the variables in the modifier.

The compiler will show an error

DeclarationError: Undeclared identifier.
        uint b = ID;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.