I've created my own struct:

 enum TestState {noWager, wagerMade, wagerAccepted}

And my modifier:

modifier onlyState(GameState expectedState){
    if(expectedState == currentState){ _;}

I'm wanting to allow a function to be carried out if it is either noWager or wagerMade state.

 function testWager() onlyState(GameState.noWager || GameState.wagerMade) payable returns(bool){....}

I am getting the error:

 || not compatible with types enum GameState and enum GameState

1 Answer 1


Here's one way to do it:

pragma solidity ^0.4.2;

contract Test {
    enum GameState {noWager, wagerMade, wagerAccepted}

    GameState public currentState;

    modifier onlyState(GameState expectedState) {
        if (expectedState != currentState) {

    modifier onlyStates(GameState expectedState1, GameState expectedState2) {
        if (expectedState1 != currentState && expectedState2 != currentState) {

    function testWager() onlyStates(GameState.noWager, GameState.wagerMade) payable returns (bool) {


And the Browser Solidity screenshot showing the successful compilation:

enter image description here

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.