August 2019
Intermediate to advanced
486 pages
13h 52m
English
The bytes data type in Solidity is a dynamically sized byte[] array. As it's dynamic sized, the length of this type can grow and shrink. The bytes type is a bit different from bytes1 , bytes2, ... bytes31, and bytes32 types (stepping 1), as bytes stores tightly packed data, whereas bytesN does not.
The bytes type variables are initialized with an empty string. If you check with the Remix IDE, it will return 0x, meaning a byte[] array with a length of 0.
There is no operator supported directly on bytes, but sometimes you might need to compare the two bytes variables. To check equality, you can compute the keccak256 hash of both the variables and perform a comparison, like that shown in following code example: ...