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 ); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.