How to traverse a mapping in Solidity (Blockchain)

21 Views Asked by At

Given the following structure, how do I create a function to loop through the addressInfo and return the address, ownerName and balance.

struct AddressInfo {
   string ownerName;
   uint256 balance;
   bool allowed;
}

mapping(address => AddressInfo) public addressInfo;

I imagined that I could go through the mapping as an array, but the mapping doesn't even have a length to define within the for.

0

There are 0 best solutions below