0

this is the solidity version:

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

this is the function that throws error:

function withdraw(uint withdrawAmount) external {
        if (withdrawAmount<1000000000000000000){
            payable(msg.sender).transfer(withdrawAmount);
        }
    }

Error Message: ParserError: Expected primary expression.

terminal underlines payable

enter image description here

1 Answer 1

0

You must be using a compiler version < 0.6.0.

The payable cast was introduced in 0.6.0.

Conversions from address to address payable are now possible via payable(x), where x must be of type address

If you want to use this syntax, use a more recent compiler version (> 0.6.0) .

3
  • I mentioned the version in the question.
    – Yilmaz
    Commented Nov 10, 2021 at 11:50
  • pragma solidity >=0.4.22 <0.9.0;
    – Yilmaz
    Commented Nov 10, 2021 at 11:50
  • No, this is your file pragma, meaning that you allow compilation by a compiler version 0.4.22 to 0.9.0 (excluded) , your actual compiler version can be any version in the range. Given your error, you are actually using a compiler version < 0.6.0. Can you show your truffle configuration file ? especially the compiler settings if it is present ?
    – hroussille
    Commented Nov 10, 2021 at 11:54

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.