1

I'm not sure if this is a legit concern but I would still want to know. If anyone can enlighten me. I know that the address.transfer() method is mostly viewed as the safest way to send eth within the contract so this is what I mostly use that is why I want to know if it can prevent an underflow or an overflow even though it is highly unlikely that someone can acquire that much ether [Please refer to the note as well] to cause an overflow.

Note that there is not enough ETH in existence to cause an overflow, the total amount of wei fits well within 256 bits

3
  • 2
    Note that there is not enough ETH in existence to cause an overflow, the total amount of wei fits well within 256 bits Commented Oct 5, 2018 at 3:37
  • Right, I am aware of that as well. Please let me include this bit to my question and rephrase this part even though it is highly unlikely that someone can acquire that much ether to cause an overflow. Thank you
    – vhie
    Commented Oct 5, 2018 at 3:51
  • Interesting question. Hope this gets more answers. +1 from me
    – R.D
    Commented Oct 5, 2018 at 3:59

2 Answers 2

2

The address.transfer() method will prevent any unintended underflow from an account. It will cause a revert in these situations, and stop the entire transaction from occurring.

1

The total ether supply is 102 million and 1 ether equals 10^18 wei. That amounts to about total wei supply 10^26 wei which fits into 87 bits (take the binary logarithm of total wei supply). There shouldn't be any overflow problem with the amount parameter because it is a uint256.

1
  • Yes, just as @Tjaden Hess♦ already said and I've also added his note to the question.
    – vhie
    Commented Oct 5, 2018 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.