Skip to content

Instantly share code, notes, and snippets.

@hackingbeauty
Created September 14, 2020 21:19
Show Gist options
  • Save hackingbeauty/571b4c50658347717b25db91085482fc to your computer and use it in GitHub Desktop.
Save hackingbeauty/571b4c50658347717b25db91085482fc to your computer and use it in GitHub Desktop.
pragma solidity ^0.6.10;
import "https://github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol";
contract Reentrance {
using SafeMath for uint256;
mapping(address => uint) public balances;
function donate(address _to) public payable {
balances[_to] = balances[_to].add(msg.value);
}
function balanceOf(address _who) public view returns (uint balance) {
return balances[_who];
}
function withdraw(uint _amount) public {
if(balances[msg.sender] >= _amount) {
(bool result, bytes memory data) = msg.sender.call.value(_amount)("");
if(result) {
_amount;
}
balances[msg.sender] -= _amount;
}
}
fallback() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment