Skip to content

Instantly share code, notes, and snippets.

@andreafspeziale
Created July 10, 2019 17:29
Show Gist options
  • Save andreafspeziale/1ad376d489d909546e6b3536467ace6f to your computer and use it in GitHub Desktop.
Save andreafspeziale/1ad376d489d909546e6b3536467ace6f to your computer and use it in GitHub Desktop.
Solidity function which concatenates the bytes array items
/**
* @dev Returns primitive bytes type from an array of bytes.
* @param items The bytes array.
*/
function concatBytes(bytes[] memory items)
private
pure
returns(bytes memory)
{
bytes memory data = items[0];
for (uint i = 1; i < items.length; i++) {
data = abi.encodePacked(data, items[i]);
}
return data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment