0

I am trying to create a modifier that will cause a function to revert if a bool from an imported contract is = to true.

This is the modifier I am trying to make

  modifier notCompleted() {
    require(
      exampleExternalContract.completed = false
    );
    _;
  }

This is the imported function and variable.

bool public completed;

function complete() public payable {
    completed = true;
}

Solidity gives me the error: Expression has to be an lvalue.

1 Answer 1

1

First, your code should be

  exampleExternalContract.completed == false // notice the double equal

Second, please have a read here https://ethereum.stackexchange.com/a/19391/45721

You should consider implementing a method and make it external

e.g

function whatIsComplete() external returns(bool) {
  return completed;
}

and in your modifier have

require(
  exampleExternalContract.whatIsComplete() == false
);

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.