diff options
author | chriseth <c@ethdev.com> | 2015-12-10 19:34:46 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-12-10 19:34:46 +0800 |
commit | 9fd72008472363fb15f9c7751899aa0b67f2e129 (patch) | |
tree | f7c062894fcd5a237710f1d16aa3e873b7872256 /docs | |
parent | 15a1468c3fcf520b9c8f0af22159ea729cf9f085 (diff) | |
download | dexon-solidity-9fd72008472363fb15f9c7751899aa0b67f2e129.tar.gz dexon-solidity-9fd72008472363fb15f9c7751899aa0b67f2e129.tar.zst dexon-solidity-9fd72008472363fb15f9c7751899aa0b67f2e129.zip |
Overflow check.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/frequently-asked-questions.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index 94491381..fd68aa11 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -742,6 +742,20 @@ If you want to send 20 Ether from a contract to the address `x`, you use `x.send Here, `x` can be a plain address or a contract. If the contract already explicitly defines a function `send` (and thus overwrites the special function), you can use `address(x).send(20 ether);`. +What does the following strange check do in the Custom Token contract? +====================================================================== + +:: + + if (balanceOf[_to] + _value < balanceOf[_to]) throw; + +Integers in Solidity (and most other machine-related programming languages) are restricted to a certain range. +For `uint256`, this is `0` up to `2**256 - 1`. If the result of some operation on those numbers +does not fit inside this range, it is truncated. These truncations can have +`serious consequences <https://en.bitcoin.it/wiki/Value_overflow_incident>`_, so code like the one +above is necessary to avoid certain attacks. + + More Questions? =============== |