Challenge 12
tx.origin Misuse
MediumWithdrawal logic
Challenge
Review the withdrawal flow, its balance checks, and the order in which funds and accounting state are updated.
Starter code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract FallbackIssue {
mapping(address => uint) public balances;
function deposit() public payable {
balances[msg.sender] += msg.value;
}
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount, "Insufficient balance");
// Review the transfer and balance-update order.
}
}Show hint
Validate the balance and update accounting safely around external calls.