Data location must be "calldata" for parameter in external function,

by Kevvv   Last Updated May 23, 2020 00:28 AM

I'm getting the following error:

Data location must be "calldata" for parameter in external function, but "memory" was given.

for the following function:

    function _registerAirline(address addr, string memory name)
        external
        requireIsOperational
    {
        require(!airlines[addr].isRegistered, "Airline is already registered");

        airlines[addr] = Airline({
            name: name,
            isFunded: false,
            isRegistered: true
        });

        multiSig.push(addr);
        emit AirlineRegistered(
            airlines[addr].name,
            airlines[addr].isFunded,
            airlines[addr].isRegistered
        );
    }

But, when I change the string memory name to string calldata name and compile, I get an error:

ParserError: Expected ',' but got identifier
function _registerAirline(address addr, bytes calldata name)
                                                       ^--^


Related Questions


Thinking through from traditional DB to ETH

Updated November 13, 2018 05:28 AM

How to decode Tx data? Online tool?

Updated January 23, 2019 10:28 AM