pragma solidity ^0.4.0;

// delete an array of names
contract ArrayDelete {
string[] names;

function main() returns (string[]) {

   delete names[0];
   return names;

Any ideas why this error occurs? None of the answers on similar questions was helpful in fixing this.

1 Answer 1


You can't return a dynamic array of dynamic arrays from a Solidity function. From the Solidity docs:

Is it possible to return an array of strings (string[]) from a Solidity function?

Not yet, as this requires two levels of dynamic arrays (string is a dynamic array itself).

  • 5
    "You can't return a dynamic array from a Solidity function." This is inaccurate. You can return a dynamic array, but you can't return a dynamic array of dynamic arrays. (string is a dynamic array.) So a return type of uint256[] is fine but not string[].
    – user19510
    Jan 26, 2018 at 21:51
  • 1
    So anything method that has to deal with something similar will have make use of numbers? What's the work around for doing this with strings ? Jan 26, 2018 at 21:52
  • It's 2022 and this is no longer a problem, thanks to ABIEncoderV2 which is enabled by default since Solidity v0.8. You can safely return a dynamic array of dynamic arrays, such as string[]. Jul 14, 2022 at 9:11

Your Answer

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

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