The startGame() function is used to start playing the blackjack game without checking the ETH balance in the TwentyOne contract. The user must pay an ETH to play, so the user's wins are not awarded.
The startGame() function allows users to play a game by not checking the reward in the TwentyOne contract.
TwentyOne.sol#L93
When the user wins the game, the reward must be paid to the user at the end of the game by the code payable(player).transfer(2 ether) in the endGame() function.
TwentyOne.sol#165
If the balance is not enough to pay a reward, the user's playing cost will stuck in the contract and will not get the winning reward.
Users lose their playing ETH without winning a reward.
Manual code reading.
I recommend checking that the contract has enough ETH to pay the winning reward before users start playing a game to prevent the lost playing cost and consider the case where multiple players are simultaneously.
The consideration of multiple user play at the same time can be checked by adding a tricker in the contract and increasing by 1 in the startGame() function in the following example code line 14 and decreasing it by 1 in the endGame() function in the following code line 28 then check the contract balance is enough to pay all of playing user in the startGame() function in the following example code line 6.
TwentyOne.sol
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.