Simple contract:
contract ex {
address[] users;
function addUser() public {
users.push(msg.sender);
}
function returnUsers() constant returns (address[]) {
return users;
}
}
In web3js I have the contract instance exInstance:
var abi = { /* some ABI */ };
var exInstance = web3.eth.contract(abi).at(someaddress);
function getUsers(){
let users = exInstance.returnUsers.call();
}
And the result is that users is a null. Tried async:
function getUsers(){
exInstance.returnUsers.call(function(error, users)
/// some actions
}
But still null
.
Am I doing something wrong or I just should iterate it in web3js and in contract just use something like returnUsers(uint i) constant returns (address) { return users[i]; }
?