Gasless Games
The ChessWager contract has the ability to verify game moves in a gasless manner. This means that players do not need to submit a transaction for each move on the chessboard.
The signed chess moves are stored off-chain until the game results in a checkmate. At this point the winner of the game submits the signed moves to the ChessWager contract, which verifies that the moves were signed by both parties and updates the state of the game accordingly.
Game Delegation
To prevent metamask from interupting gameplay each time a player makes a move on the chessboard, users delegate their signature to a wallet generated on the ChessFish frontend.
Game delegation is achieved in the following steps:
- The user signs the string of the game address.
- The signed message data is hashed.
- The hash is used as a deterministic seed for generating a new wallet mnemonic.
- The new wallet signs the game moves under the hood, without the user's metamask requesting a signature for each move.
- The signature delegation data is passed to the smart contract when submitting all the moves to verify that the user did indeed delegate their signature.
How it works:
- ChessWager.sol uses ECDSA signatures to determine the authenticity of the submitted moves.
- The move verification contract ensures that the game moves are signed by the correct player and are in the correct order.
- Invalid chess moves or signatures lead to transaction reversion.
The ChessFish contracts use the ERC-712 standard to implement typed signatures.