Created
September 14, 2020 21:16
-
-
Save hackingbeauty/8b673e4e0d0df30c079d7794a45ed7d5 to your computer and use it in GitHub Desktop.
DAOWallet.sol (SmartContractSecurity.com)
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
| pragma solidity ^0.6.10; | |
| contract DAOWallet { | |
| mapping(address => uint) public balances; | |
| bool internal locked; | |
| function deposit() public payable { | |
| balances[msg.sender] += msg.value; | |
| } | |
| modifier noReentranct() { | |
| require(!locked, "Absolutely no re-entrancy!"); | |
| locked = true; | |
| _; | |
| locked = false; | |
| } | |
| // mutex | |
| function unsafeWithdraw(uint _amount) public noReentranct { | |
| require(balances[msg.sender] >= _amount); | |
| (bool sent, ) = msg.sender.call{value: _amount}(""); | |
| require(sent, "Money transfer failed!"); | |
| balances[msg.sender] -= _amount; | |
| } | |
| function getAccountBalance() public view returns (uint) { | |
| return address(this).balance; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment