Skip to main content
Solidity Output Prediction Medium +20 XP

Modifier Effect

What does the onlyOwner modifier do?

SolidityRead-only
modifier onlyOwner() {
  require(msg.sender == owner);
  _;
}

What is the output?

Show answer and explanation

Answer: Restricts function to contract owner

require() reverts if the condition is false. _; runs the modified function's body. Together they gate access to the owner.

Hint: require() reverts on failure.

What this challenge tests

Output Prediction in Solidity: modifiers, access-control.

Related challenges