1

Why is data location not required to be specified for bytes32?

2
  • Hello. Please give us more details about your question. What do you mean by "data location not required" ? What exactly are you talking about ? What type would require it ? May 3, 2021 at 9:07
  • 2
    @FlorianCastelain In solidity, there are 4 types of data location: storage, calldata, stack and memory. Data location must be explicitly specified in solidity for arrays, bytes and structs. May 3, 2021 at 20:06

1 Answer 1

3

Whether or not you need to declare memory, storage, or calldata depends on if your variable is a "complex" variable or not. (See the note here.) This means things like structs and arrays. Simpler types are automatically assigned storage - see this question and anwser.

To answer fully, bytes32 will automatically be storage even without a data location declaration.

2
  • 1
    Thanks, that fully answered it! May 3, 2021 at 20:07
  • bytes is a monster that probably should have gotten a different name to distinguish it further from the simple types like bytes32.
    – eth
    May 7, 2021 at 1:25

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.