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.

Rohan Nero
  • 1,562
  • 2
  • 7
  • 27

1 Answers1

0

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
);
Iulian
  • 640
  • 5
  • 18