1

I'm new to Solidity and Truffle. I'm trying to compile my Solidity code within Truffle to create an ERC-20 token. I have @truffle/hdwallet-provider and @openzeppelin/contracts as my dependencies. Now, I only have two Solidity files, both of which have pragma solidity ^0.6.0;. I have been uninstalling and reinstalling to different versions and changing the compiler version in truffle-config.js to whichever the error message is telling me to change as well as changing the pragma solidity versions in the two files I have. I also had to change the individual files in node modules to fit the right version.

Finally, I think the change in the version from ^0.6.2 to ^0.6.0 broke a file called Address.sol in the utility folder of contracts in Node Modules:

    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{ value: amount }(""); // here
        require(success, "Address: unable to send value, recipient may have reverted");
    }

The error message shows:

ParserError: Expected ';' but got '{'

indicating the point right after call.

First, how do I fix this? And second, is this version incompatibility issue what I should expect every time there's been updates in either Truffle, Solidity, or any of my dependencies?

1 Answer 1

1

The reason the compilation stopped working is because that way of performing a call was only made available in Solidity 0.6.2:

Allow gas and value to be set in external function calls using c.f{gas: 10000, value: 4 ether}().

Prior to 0.6.2, you had to use c.gas(_gasLimit).value(_value)(_data);

This change is simply an added feature and not a breaking change. You can use the latter call format for any version of solidity, both pre- and post- 0.6.2. The new version was introduced as a convenience and not as a mandatory way to do it.

2
  • 2
    thank you for your answer. So how do I reformat (bool success, ) = recipient.call{ value: amount }("");?
    – Kevvv
    May 10, 2020 at 0:30
  • I believe you can do it like this: recipient.call.value(amount)(""); May 10, 2020 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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