Last active
February 1, 2023 17:25
-
-
Save bartubozkurt/f72df64bc342058391bc718a705d6b86 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* Bad */ | |
function badWithdraw(uint amounts) public { | |
require(amounts <= balances[msg.sender]); // 1.πππππ | |
(bool success, bytes memory data) | |
= msg.sender.call{value: amounts}(""); // 3.ππ‘π§ππ₯πππ§ππ’π‘ | |
require(success); | |
balances[msg.sender] - amounts; // 2.ππππππ§π¦ | |
} | |
/* Better */ | |
function goodWithdraw(uint amounts) public { | |
require(amounts <= balances[msg.sender]); // 1.πππππ | |
balances[msg.sender] - amounts; // 2.ππππππ§π¦ | |
(bool success, bytes memory data) | |
= msg.sender.call{value: amounts}(""); // 3.ππ‘π§ππ₯πππ§ππ’π‘ | |
require(success); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment