The createGameWithToken
and joinGameWithToken
functions lack explicit checks for token allowances before transferring players' RPSW tokens to the contract. This oversight may cause transactions to revert unexpectedly if users have not properly approved the contract to spend their tokens, leading to a poor user experience and potential confusion.
createGameWithToken
Purpose: Allows players to create a game using RPSW tokens instead of ETH.
Issue: Calls transferFrom
without verifying allowance
for the contract.
joinGameWithToken
Purpose: Allows players to join a token-based game.
Issue: Similar missing allowance check before transferFrom
.
ERC20 tokens require explicit approval via approve
or increaseAllowance
before a contract can transfer tokens on behalf of a user. While transferFrom
inherently checks the allowance, failing to include explicit require
statements for allowance validation results in opaque transaction reverts with generic errors (e.g., "ERC20: insufficient allowance"). This makes debugging difficult for end-users.
User Experience Degradation: Transactions may fail silently without clear error messages, confusing users.
Potential Frontend Misalignment: If frontends assume allowance checks are handled by the contract, improper error handling could lead to UI inconsistencies.
No Direct Fund Loss: The bug does not risk fund loss but disrupts protocol usability.
Manual code review
Foundry/Forge
Add explicit require
statements to validate token allowances before calling transferFrom
in both functions.
createGameWithToken
Function:joinGameWithToken
Function:Added require(winningToken.allowance(...))
checks (highlighted) to explicitly validate token allowances.
Error messages now clearly indicate insufficient allowance issues.
Frontend Guidance: Ensure frontend applications prompt users to approve token allowances before initiating transactions.
Event Logging: Emit events after successful approvals to assist in tracking user interactions.
createGameWithToken and joinGameWithToken functions will revert because they attempt transferFrom without requiring the user to first approve
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.