Last active
April 8, 2019 13:33
-
-
Save daniellehrner/c134ce5cd1b9bb660ec76620bb3d7e8c to your computer and use it in GitHub Desktop.
Iterable Eternal Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addAddressKey("balanceKeys", "0x12..."); | |
function addAddressKey(bytes32 _listId, address _value) external { | |
// get the number of keys with _listId "balanceKeys" | |
uint256 size = getUInt256(keccak256(abi.encodePacked(_listId, "KEY_SIZE"))); | |
// the new index (end of the list) is equal to the size of the keys | |
uint256 index = size; | |
// store _value as last item in the list | |
setAddress(keccak256(abi.encodePacked(_listId, "KEY_VALUES", index)), _value); | |
// increase the size of the list by one | |
setUInt256(keccak256(abi.encodePacked(_listId, "KEY_SIZE")), size + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment