The random logic on the dealer hand is high probability to get bust (it is >=50%). In the long run the player will gain all of ETH in the contract.
The dealer hand is depend on the standThreshold
(stop drawing a card when the dealer hand value is in the threshold) which is calculate by random number mod by 5 and plus by 17.
TwentyOne.sol
From the code above, there are 5 possible value of the standThreshold
: {17, 18, 19, 20, 21}.
The dealer need to draw a card to match the value within the randomed threshold.
By our simulation of card drawing using following python code to calculate the bust chance in each threshold:
insecure-blackjack-simulation.py
Result:
The bust probability in each threshold by overall is >=50% by ignoring the player hand.
Threshold | Bust Probability |
---|---|
17 | 29.73% |
18 | 39.75% |
19 | 51.05% |
20 | 63.88% |
21 | 83.14% |
This shows the chance that the dealer will lose to the player regardless of the player's hand. When the player's hand is greater than the threshold, the chance that the dealer will lose increases.
In the long run overall players will win the dealer.
In the worst case, the player may play multiple times, then the dealer loses all the ETH in the contract.
Manual code reading and using python programing to calculate probabilities.
I recommend limiting the bust chance by removing the randomness of the standThreshold
and fixed it to 17
to reduce the bust chance for example:
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.