For each token game, there are two winnings/bet tokens locked inside the game smart contract.
When a game token is created with the function createGameWithToken
, the winning token is transfered to the game smart contract.
This is also the case when a player B wants to join the game by calling the function joinGameWithToken
But when the winner is chosen, instead of transferred the tokens inside the contract to the winner, the game mints new tokens in the function _finishTokens
.
There is the same problem in the function _cancelGame
This design generates several problems:
The two Winning tokens transferred are locked inside the game contract
The total supply of the token is "artificially" increased
The game smart contract must have the minter role on the token, which is not necessary for this use case. It reduces also the possibility in the futur to use another ERC-20 token (e.g USDC) as a winning token for a token game.
Use safeTransferFrom from OpenZeppelin to transfer the token from the game smart contract to the winner instead of minting new tokens.
Mints new tokens upon game completion or cancellation for token-based games
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.