The claimThrone function is intended to allow a new player to become the currentKing by paying a fee. This is the central mechanic of the game, allowing for a "King of the Hill" style competition.
The core logic of the claimThrone function contains an inverted require statement. Instead of checking that the claimant is not the current king, it checks that the claimant is the current king. Since the game starts with currentKing as address(0), this check always fails for the first player, preventing anyone from ever becoming king and freezing the game in its initial state.
Likelihood: High
This bug occurs on the very first attempt to call claimThrone in any game round.
It is a certainty that every deployed instance of this contract is immediately and permanently unplayable.
Impact: High
The contract's core functionality is completely broken. No player can ever become the king, and the game cannot proceed past its initial state.
The contract fails to serve its purpose, leading to a total loss of user trust and a failure of the application.
The following Foundry test simulates a full game lifecycle and proves that the game is stuck from the beginning. It shows that the first player's attempt to claim the throne is reverted, the currentKing is never updated, and as a result, a winner can never be declared.
The logical operator in the require statement within the claimThrone function must be inverted from == to !=. This ensures that a player can only claim the throne if they are not already the current king.
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.