Guest User

Untitled

a guest
Jun 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function getData() public view {
  2. uint length;
  3. for(uint i = 0; i<6; i++) {
  4. length += data[i].length;
  5. }
  6. bytes memory result = new bytes(length);
  7.  
  8. uint index = 32; // bytes is an array, and in EVM the first
  9. // 32 bytes of an array stores the length
  10. // of the array, so add data 32 byte in
  11.  
  12. for(i = 0; i < 6; i++) {
  13. bytes memory oneSixth = new bytes(data[i].length);
  14. oneSixth = data[i];
  15. assembly {
  16. mstore(add(result, index), add(oneSixth, 32))
  17. }
  18. index += data[i].length;
  19. }
  20. }
Add Comment
Please, Sign In to add comment