Solidity Mapping – How to Return Multiple Values from a Mapping

mappingsolidity

I have been stuck on this for a while, I have a mapping
mapping (uint => bytes) idToEmail;

A function to populate the mapping
function addRecord(uint id, bytes email) public payable { idToEmail[id] = email; }

I need a function to fetch multiple values for an input of multiple keys, like
function fetchRecords(uint[] ids) returns (bytes[]) {..}

How do I go about doing this?

Best Answer

You cannot return a dynamic array in solidity at the moment however, you can return a byte array of fixed size. Try Solidity: Can you return dynamic arrays in a function? for more information

Related Topic