So, I'm realizing that solidity does not allow you to use abi.encodePacked on arrays. I want to be able to return a 2 dimensional uint array printed out and concatenated with other strings. I'm trying to do this with metadata for an NFT. Does anyone know any tricks?


  • Can you share an example data of what you are trying to do?
    – pbsh
    Feb 4, 2022 at 8:56
  • for sure, something like this: string internal svgStart = '<svg.......' string internal svgEnd = '.....</svg>' function getSvg(uint[2][] memory list) public view returns (string memory) { return string(abi.encodePacked(svgStart, list, svgEnd)); } Feb 4, 2022 at 17:30
  • I thought it would format better... let me know if it doesnt make sense Feb 4, 2022 at 17:31

1 Answer 1


try this:

pragma solidity ^0.8;

contract MyContract {
    function concat(string[] calldata words) external pure returns (string memory) {
        bytes memory output;

        for (uint256 i = 0; i < words.length; i++) {
            output = abi.encodePacked(output, words[i]);

        return string(output);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.