Tips: Reentrancy
Reentrancy
contract Wallet {
address public owner;
mapping (address => uint) public balances;
constructor() public {
owner = msg.sender;
}
function deposit() public payable {
balances[msg.sender] += msg.value;
}
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
msg.sender.transfer(amount);
balances[msg.sender] -= amount;
}
function pay(address payable _to, uint amount) public {
require(balances[msg.sender] >= amount);
_to.transfer(amount);
balances[msg.sender] -= amount;
}
}Mitigation
Detecting Reentrancy
Preventing Reentrancy
Reentrancy Hack
Last updated