Member-only story

Solidity Tutorial : all about Bytes

Jean Cvllr
11 min readAug 1, 2019

Bytes are a large aspect of Solidity, whether when using fixed size bytesN or dynamic size bytes array. We will see in this article their difference, bitwise operations related to fixed-sized array bytesN and we can use them to perform some generic methods like concatenating.

Table of Content :

  1. Endianness & bytes data layout in Solidity
  2. Fixed-size byte arrays
  3. Dynamically-size byte arrays
  4. Bitwise operations in Solidity
  5. An array of bytes = a little difference
  6. Bytes as function arguments
  7. Conversion between addresses and bytes20
  8. Advanced operations with Bytes
  9. A word of warning with Solidity bytes

1. Endianness & bytes data layout in Solidity

Introduction to Endianness

In computing, the term endianness corresponds to how the low level bytes of any data are stored and ordered. Therefore, it defines the internal ordering of the computer or machine memory.

We refer to multi-byte data types data that its t(uint, float, string, etc…). There are two ways for ordering multi-byte data types in computer: in…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jean Cvllr
Jean Cvllr

Written by Jean Cvllr

Smart Contract engineer at @LUKSO. Full Stack Developer. https://github.com/CJ42

Responses (5)

What are your thoughts?

Nice article! Just one clarification- For the little endian representation of 0x61626364, I think you missed the part to reverse the bytes in the 32 bytes representation.
It should be 0x000...64636261, right?

Gread article! But Solidity use only big endian. Strings are left-aligned and numbers are right-aligned.

Thanks for the deep dive, Jean. I would like to hint to the holy bible of bytemanipulation: Hacker's Delight by Henry S. Warren. It's amazing how relevant the programming tricks still are.