Last active
April 5, 2019 15:04
-
-
Save daniellehrner/c7f809eb62201592cdba458991a4f2e3 to your computer and use it in GitHub Desktop.
Wrapper function to store a balance in 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
function setBalance(address _who, uint256 _value) external { | |
setUInt256( | |
// computes the Ethereum-SHA-3 (Keccak-256) hash | |
keccak256( | |
// performs packed encoding of the given arguments, | |
// as the hash function only accepts one argument | |
abi.encodePacked( | |
// we use a hardcoded string to create a different | |
// hash for the same dynamic value | |
"balance", | |
// a unique dynamic value is needed to clearly | |
// assign the value to an account | |
_who | |
) | |
), | |
// the value we want to store | |
_value | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment