I'm trying to build a function that, when called, returns a mapping
as two different array.
The problem that I have a mapping (address => uint) content2view
and I have to get this value outside solidity. So, I wrote a function
mapping (address => uint) content2view;
address[] contents;
/* [...] */
function getStatistics() external view returns (address[], uint[]){
address[] memory resAddr;
uint[] memory views;
for(uint i = 0; i<contents.length; i++){
resAddr[i] = contents[i];
views[i] = content2view[contents[i]];
}
return (resAddr, views);
}
The problem is that, when I call it with remix, no value is returned and the transaction is aborted:
VM error: invalid opcode.
invalid opcode
The execution might have thrown.
Debug the transaction to get more information.
Of course, I don't see any error and I don't understand which invalid opcode is invalid... Any help?