I know what is difference between memory and calldata. But seeing that I ask this question I don't seem to understand deeply yet.

I ran into an error message as below, when I used 'calldata' as a data location for constructor input argument.

"Data location must be "storage" or "memory" for constructor parameter, but "calldata" was given."

But, in constructor, I just only read the value to allocate storage without any changes.

Like example below,

pragma solidity 0.8.10;

contract Example {
   address theFirst;
   constructor(address[] calldata _addressList) {
      theFirst = _addressList[0];
  • bro the error is saying every thing ; i think calldata is only for parameter's of function's with implementation ( with {}). May 21, 2022 at 21:42

1 Answer 1


It's because the constructor is a special kind of function and how it gets called.

The contract is written to chain followed immediately by the constructor parameter data. The constructor then reads the parameter values by looking them up at that offset.

So, constructor parameters specifically are not of type calldata.

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.