The function claimThrone() in /src/Game.sol incorrectly prevents anyone from claiming the throne - including the first player. This due to a faulty logic check.
At deployment, currentKing == address(0)
. When any user attempts to claim the throne for the first time, this check will always fail, since msg.sender != adress(0). As a result, no one can ever start the game, and the contract becomes unusable.
##Risk: High
Likelihood: 100%
This issue will always occur immediatly after deployment, because the currentKing is initialized to address(0) and no one can match that address.
It completely blocks the first interaction with the game (first claim), since currentKing is intialized to addrress(0), and no msg.sender can match that.
Impact: total game failure
Users cannot participate in the game, because the claimThrone() function always reverts on the first attempt.
The contract non-functional and useless, defeating the purpose of the game.
Any ETH sent to it is effectively locked.
This test simulates a user trying to claim the throne immediately after deployment. Since currentKing == address(0)
and msg.sender != address(0)
, the call reverts. The game cannot be started.
The intention is to prevent the same player from repeatedly claiming the throne - not to block everyone. Replacing ==
with !=
fixes the logic and allows new players to claim, while still preventing reduntant self claims.
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.