la fonction est elle correcte ? "function withdraw(uint256 gameId, address…
Jump to turn (8)
- 1la fonction est elle correcte ? "function withdraw(uint256 gameId, address curre
- 2winner est défini de cette manière estce correct ?
- 3winner est défini de cette manière estce correct ? "address public winner;"
- 4vous devez affecter une valeur à la variable “winner” avant d’utiliser la condit
- 5suivant la fonction "withdraw" : function withdraw(uint256 gameId, address curre
- 6"Dans la ligne “await penduelInstance.winner({ from: currentPlayer });”, vous de
- 7pourquoi ai je cette erreur "Error: VM Exception while processing transaction: r
- 8" it("devrait permettre au gagnant de retirer avec succès", async () => { const
- User
la fonction est elle correcte ? "function withdraw(uint256 _gameId, address _currentPlayer, uint256 _amount) public payable { require(_currentPlayer == games[_gameId].player1 || _currentPlayer == games[gameId].player2, "You re not a player");
coderequire(!(_currentPlayer == games[_gameId].player1 && games[_gameId].player1HasWithdrawn) && !(_currentPlayer == games[gameId].player2 && games[gameId].player2HasWithdrawn), "withdrawn balance"); uint256 balance = playerBalances[_gameId][_currentPlayer].balance; require(balance >= _amount, "Insufficient balance"); if (_currentPlayer == winner){ playerBalances[_gameId][_currentPlayer].balance = balance - _amount; (bool success, ) = payable(_currentPlayer).call{value: _amount}(""); require(success, "The withdrawal failed"); } if (_currentPlayer == games[_gameId].player1) { games[_gameId].player1HasWithdrawn = true; } else { games[_gameId].player2HasWithdrawn = true; } emit Withdraw(_gameId); }