I have a contract with a mapping inside a struct
contract Voting {
struct voter {
address voterAddress;
uint256 tokensBought;
mapping (bytes32 => uint256) tokensUsed;
}
mapping (address => voter) public voterInfo;
}
I want a function that returns voter information given an address. I found out I can not have a function return a Struct. So, I tried writing a function which returns tokensBought and tokensUsed like below:
function voterDetails(address user) returns (uint256, mapping (bytes32 => uint256)) {
return (voterInfo[user].tokensBought, voterInfo[user].tokensUsed);
}
When I try to compile this code, I get the following errors:
Error: Type is required to live outside storage.
Error: Internal type is not allowed for public or external functions
Looks like I can't return mapping type in a function. How do I write a function that returns all the voter information?