Skip to content

Instantly share code, notes, and snippets.

@hackingbeauty
Created September 14, 2020 21:16
Show Gist options
  • Save hackingbeauty/8b673e4e0d0df30c079d7794a45ed7d5 to your computer and use it in GitHub Desktop.
Save hackingbeauty/8b673e4e0d0df30c079d7794a45ed7d5 to your computer and use it in GitHub Desktop.
DAOWallet.sol (SmartContractSecurity.com)
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