Modifiers in solidity

Viewed 120

I am writing a contract where a funcion can be modified by the valid user or the admin.

Can I use two modifiers in the same function and the function can be accessed if either one of the modifiers succeed?

Or is there any way to make the admin bypass all modifiers and conditions?

1 Answers

You can create a simple modifier that checks both conditions.

modifier onlyAllowedUsers {
  require(validUser[msg.sender] || admin == msg.sender, "Error Message");
  _;
}

Supposing validUser is a mapping that maps addresses to booleans.

Related