Assignment 4 – modifier, error handling

Published by Mario Oettler on

Write a smart contract with a function called setName. It should take a string as parameter and save it in a public state variable called name.

Restrict the access to this function via a modifier so that only the account that created (deployed) this contract can set the name. You can call this modifier onlyOwner.

The modifier should return an error message.

Implement this by using:

  1. require() or
  2. custom error