0
pragma solidity >=0.4.22 <0.6.0;
interface ERC20 {
    function balanceOf(address owner) external view returns (uint256);
}
contract BalanceOracle {
    
    function exploreBalances(address[] calldata users) external view returns(uint256[] memory balances) {
        balances = new uint256[](users.length);
        for(uint i = 0; i < users.length; i++) {
            balances[i] = users[i].balance;
        }
    }
    
    function erc20Balances(address _token, address[] calldata users) external view returns(uint256[] memory balances) {
        ERC20 erc20 = ERC20(_token);
        balances = new uint256[](users.length);
        for(uint i = 0; i < users.length; i++) {
            balances[i] = erc20.balanceOf(users[i]);
        }
    }
}

ParserError: Expected ',' but got identifier function erc20Balances(address[] _token, address calldata user) external view returns(uint256[] memory balances) { ^--^

1 Answer 1

0

The calldata keyword was added at Solidity 0.5.0.

If you are compiling this contract with Solidity 0.4.X you have to remove it, and with 0.5.X you must add it as the 0.5.0 changelog states :

Explicit data location for all variables of struct, array or mapping types is now mandatory. This is also applied to function parameters and return variables. For example, change uint[] x = m_x to

As a side node, your pragma shouldn't span across minor versions as those can introduce breaking changes (hence your question). This answer could be very informative for you.

0

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.