Code has been added to clipboard!

Fixed Size Bytes Conversion in Solidity

Example
bytes2 a = 0x1234;
bytes4 b = bytes4(a);
assert(a[0] == b[0]);
assert(a[1] == b[1]);