New answers tagged


Solidity doesn't currently support returning a mapping or a variable-sized list, so you would need to implement a getter function as you described that takes an index. The approach I think you're describing is keeping a second list next to the mapping, and using it to return the mapping in chunks like the source code below. contract SomeContract { ...


You can write the program as follows: function getArray() external view returns(uint[] memory result) { uint[] result; for (uint i = 0; i <= 3; i++) result.push(i); }


You can make a mapping of addresses to structs and include a boolean in the struct. Be sure to check this pattern: Hope it helps.


You can't do it without the experimental ABI encoder. You can turn that on with, per pragma experimental ABIEncoderV2;

Top 50 recent answers are included