0

I have a problem with this code:

function reimburse() payable external {
            require(msg.sender == borrower, 'only borrower can reimburse');
            require(msg.value = amount + interest, 'borrower need to reimburse exactly amount + interest');
            _transitionTo(State.CLOSED);
            lender.transfer(amount + interest);
        }

When I compile it in remix, it shows 2 errors which are below:

-TypeError: Expression has to be an lvalue

-TypeError: No matching declaration found after argument-dependent lookup

I really don't understand. Could someone help me to fix these problems please?

Thank you very much

Take care

0

This == is an equality operator - it checks whether both sides are equal.

This = is an assignment operator - it assigns whatever variable is on the left-hand side to whatever is on the right-hand side.

This line:

require(msg.value = amount + interest, 'borrower need to reimburse exactly amount + interest');

...should be doing an equality check. You need to change = to ==.

(For the second error, it's not clear what the issue is without seeing the rest of the code.)

1
  • Thank you so much. It solved both problems.
    – Pierre
    Jun 2 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.