Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solidity ParserError: Expected ';' but got '{'

Tags:

solidity

Using Version 0.6.0

pragma solidity ^0.6.0;

contract Test {
    function sendValue(address payable recipient, uint256 amount) external {
        (bool success, ) = recipient.call{ value: amount }("");
    }
}

Test.sol:5:42: ParserError: Expected ';' but got '{' (bool success, ) = recipient.call{ value: amount }(""); ^

Why is this error here?

like image 686
Kevin A. Avatar asked May 31 '26 21:05

Kevin A.


1 Answers

You're using syntax that was introduced in Solidity 0.7 but isn't yet valid in 0.6.

For 0.6, use this:

(bool success, ) = recipient.call.value(amount)("");

Sources and more info:

  • 0.7 syntax: https://docs.soliditylang.org/en/v0.7.0/control-structures.html#external-function-calls
  • 0.6 syntax: https://docs.soliditylang.org/en/v0.6.0/control-structures.html#external-function-calls
like image 137
Petr Hejda Avatar answered Jun 04 '26 11:06

Petr Hejda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!