I understand that I need to tell solidity where a parameter is located, for example a string:

function f(string memory abc) {...

Because a string could be calldata (passed in original method call) or it could be memory or it could be storage.

But this does not seem to be required for other types such as uint.

Why only string needs to be specified?


1 Answer 1


The location specifier is required on any reference type (as opposed to a value type).

A reference type is a variable which holds a pointer to data of interest. For example any array, a struct, bytes, or a string.

A value type is a variable which holds the data of interest. This would be the basic types such as uint, address, etc.

Just to clarify as it's a common point of confusion, string is short-hand notation for an array of bytes.

For more information, see https://solidity.readthedocs.io/en/v0.5.5/types.html#reference-types

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.