Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daniellehrner/c390df4d985b5ff71ba27a1801aeb103 to your computer and use it in GitHub Desktop.
Save daniellehrner/c390df4d985b5ff71ba27a1801aeb103 to your computer and use it in GitHub Desktop.
Iterable Eternal Storage Getter
address[] memory addressKeys = getAddressKeys("balanceKeys");
function getAddressKeys(bytes32 _listId) external view returns (address[] memory) {
// get the number of keys with _listId "balanceKeys"
uint256 size = getUInt256(keccak256(abi.encodePacked(_listId, "KEY_SIZE")));
// create an address array with the size of the list
address[] memory keys = new address[](size);
// iterate over the list
for (uint256 index = 0; index < size; index++) {
// get the value at the current index
keys[index] = getAddress(keccak256(abi.encodePacked(_listId, "KEY_VALUES", index)));
}
// return dynamic list of keys
return keys;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment