On readthedocs.io, it says that byte[] or bytes1[] elements are padded to 32 bytes. I thought at first it was for even distribution, but distribution would still be even if each element had exactly one byte of space. So, what is the purpose of this padding? Also, is this padding also added to bytes2 - bytes31?

  • I assume you're talking about the Solidity docs? (readthedocs.io hosts documentation for many projects.) In general, it would help if you linked to the exact page you're reading. – smarx Jun 10 '18 at 0:39
  • Yes, but I think I understand this better now after the article you sent me from the other question. Each storage slot has to be 32 bytes, so anything kept as an isolated element within an array will always have extra padding up to 32 bytes (if the element is smaller than 32 bytes). – CreatedAMadman Jun 10 '18 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.