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

  • 2
    Note that there is not enough ETH in existence to cause an overflow, the total amount of wei fits well within 256 bits – Tjaden Hess Oct 5 '18 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 Oct 5 '18 at 3:51
  • Interesting question. Hope this gets more answers. +1 from me – R.D Oct 5 '18 at 3:59
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.

| improve this answer | |
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.

| improve this answer | |
  • Yes, just as @Tjaden Hess♦ already said and I've also added his note to the question. – vhie Oct 5 '18 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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