pragma solidity ^0.4.24;
contract User {
mapping(uint=>address) addresses;
uint addressRegistryCount;
function set(address userAddress) public {
addresses[addressRegistryCount] = userAddress;
addressRegistryCount++;
}
function get(address userAddress) public view returns (uint) {
for (uint i = 0; i <= addressRegistryCount; i++) {
if(addresses[i] == userAddress)
return i;
}
}
/*function getAll() {
}*/
}
In this contract I have a function called getAll. Inside that function I´m trying to return the full mapping of users. How can I make that?
publicbeforeaddresses, and you've got yourself a "getAll" function (which you can invoke from the off-chain viaaddresses()). – goodvibration Jan 15 '19 at 09:20publicidentifier doesn't result in agetAllfunction. It gives you a public function which takes index as input and returns only one element of mapping. – saman.shahmohamadi Jan 15 '19 at 09:36