Skip to main content
1 of 4
BokkyPooBah
  • 40.4k
  • 14
  • 123
  • 193

Try the following:

function getUsersCount() public constant returns(uint) {
    return users.length;
}

function getUser(uint index) public constant returns(uint, string, address) {
    return (users[index].idNum, users[index].name, users[index].userAddress);
}

You should then be able use the statements:

> var numberOfUsers = contract.usersCount();
undefined
> numberOfUsers
5
> var user1 = contract.getUser(1)
[234, "User 234", "0xbeefee3ad17cd9aca6fd5343a53a513685c7e0ed"]
> var user0 = contract.users(0)
[123, "User 123", "0xbeefee3ad17cd9aca6fd5343a53a513685c7e0ed"]
BokkyPooBah
  • 40.4k
  • 14
  • 123
  • 193