New answers tagged

2

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 { ...


0

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); }


0

You can make a mapping of addresses to structs and include a boolean in the struct. Be sure to check this pattern: https://medium.com/robhitchens/solidity-crud-part-1-824ffa69509a Hope it helps.


1

You can't do it without the experimental ABI encoder. You can turn that on with, per https://solidity.readthedocs.io/en/v0.5.11/layout-of-source-files.html#abiencoderv2: pragma experimental ABIEncoderV2;


Top 50 recent answers are included