This is my struct:
struct Token {
address tokenAddress;
uint256 minAmount;
bool emergencyUnlock;
TokenStatus status;
string name;
uint256 decimal;
string thumbnailUrl;
}
and a mapping:
mapping(address => Token) private _token;
A function returns details of the token when I asked given the indexes:
function getTokens(uint256 start, uint256 length) external view returns(
address[] memory tokenAddresses,
uint256[] memory decimals,
string[] memory name
)
{
tokenAddresses = new address[](length);
name = new string[](length);
decimals = new uint256[](length);
require(start.add(length) <= _tokens.length, "Lock: Invalid input");
require(length > 0 && length <= 15, "Lock: Invalid length");
uint256 count = 0;
for(uint256 i = start; i < start.add(length); i++) {
tokenAddresses[count] = _tokens[i].tokenAddress;
count = count.add(1);
decimals[count] = _tokens[i].decimal;
name[count] = _tokens[i].name;
}
return(
tokenAddresses,
decimals,
name
);
}
Now, the problem is that, it asks me that it is not supported to return array of string. Error is below:
TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. string[] memory name
Does anyone know the work around? I know that name will not be more than 20 characters long ever.
Use "pragma experimental ABIEncoderV2;" to enable the feature. string[] memory name
!