Skip to main content
Solidity Code Completion Hard +35 XP

Custom Modifier

Complete the modifier to restrict access to the owner.

SolidityFill in the blank
modifier onlyOwner() {
  require(msg.sender == owner, "Not owner");
  ___;
}

Type the missing code

Show answer and explanation

Answer: _

The _ (underscore) in a modifier is a placeholder for the function body. It tells Solidity where to insert the modified function's code.

Hint: What placeholder executes the modified function body?

What this challenge tests

Code Completion in Solidity: modifiers, access-control.

Related challenges