I am practicing my Solidity skills and while I did expect to get an error, I did not expect this error
TypeError: This type is only supported in the new experimental ABI
encoder. Use "pragma experimental ABIEncoderV2;" to enable the
feature. function getArray() public view returns (string[]) {
This is my code in Remix:
pragma solidity ^0.4.17;
contract Test {
string[] public myArray;
function Test() public {
myArray.push("hola");
}
function getArray() public view returns (string[]) {
return myArray;
}
}
What gives here?
Is this because the standard ABI does not support dynamic nested arrays?
Best Answer
The error message you are seeing is a result of the fact that Solidity does not yet support two levels of dynamic arrays, which a
string[]
would be:The error is telling you to add an additional line to the top of your code:
This feature came in Solidity version 0.4.19, which states:
Note that in this case it does support nested arrays. I assume these features will eventually make their way into the production builds of Solidity, but it is not clear to me when. I tested, and your code does work when I add this additional
pragma
in remix.