I was going through the tutorial from DappUniversity on Youtube when I stumbled across with my enum

pragma solidity ^0.6.0;

contract HotelRoom {
  address payable public owner; /*state variable, the payment is sent to this address*/
  enum Statuses { Vacant, Occupied };
  Statuses currentStatus;
  event Occupy(address _occupant, uint _value);
  constructor() public {
      owner = msg.sender; /*this is the address of the user who calls this function*/
       currentStatus = Statuses.Vacant;
    modifier onlyWhileVacant {
        require(currentStatus == Statuses.Vacant, "Currently occupied.");
    modifier costs (uint _amount) {
        require(msg.value >= _amount, "Not enough Ether provided.")
    receive() external payable onlyWhileVacant costs(2 ether) {
        currentStatus = Statuses.Occupied; 
      emit Occupy(msg.sender, msg.value);

and the error yields this

browser/mycontract14.sol:6:37: ParserError: Function, variable, struct or modifier declaration expected enum Statuses { Vacant, Occupied };

Like I said, this is not really my own code, I'm just following along a tutorial. And sorry if my format is messy, I'm new, but ambitious!

1 Answer 1


There's a few small errors your code, but unfortunately the Solidity errors aren't very helpful in this case.

  1. After a function or enum declaration you can't use ;, so your enum should be:

    enum Statuses { Vacant, Occupied }
  2. You're missing a ; after the require in the costs modifier:

  3. You're missing a _; in the costs modifier. If you change it to the following, your code should compile.

    modifier costs (uint _amount) {
      require(msg.value >= _amount, "Not enough Ether provided.");

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.