TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

Contract May Fail to Pay Winnings Due to Insufficient Balance

Root Cause

The contract does not verify its balance before attempting to transfer winnings to the player:

if (playerWon) {
payable(player).transfer(2 ether);
emit FeeWithdrawn(player, 2 ether);
}

If the contract's balance is less than 2 ether, the transfer will fail, and the player will not receive their winnings.

Impact

  • Unpaid Winnings: Players may not receive their rightful payouts, leading to loss of trust.

  • Transaction Reversions: Failed transfers can cause transactions to revert, wasting gas fees for players.

  • Reputation Damage: The contract may be perceived as fraudulent if it cannot honor payouts.

Recommendations

  • Balance Checks: Before initiating the transfer, check if the contract has sufficient balance and handle the situation gracefully if it doesn't.

  • Funding Mechanism: Ensure the contract is adequately funded, possibly by allowing the owner to deposit funds.

  • Dynamic Payouts: Adjust the payout amounts based on the contract's current balance or implement a queue system to fulfill payouts when funds are available.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Insufficient balance for payouts / Lack of Contract Balance Check Before Starting Game

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.