project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6


A provable chess game where you can assign unique tokens and NFTs to pieces, adding complexity to strategies for a more engaging and entertaining gameplay.


Created At


Project Description

Implementation of a provable game of chess where players have the opportunity, before starting the game, to assign NFTs and tokens to their chess pieces. When a piece with tokens is captured, the capturing player receives the associated tokens, adding a new layer of strategic complexity. The winner of the chess match gets a token prize. These extra dynamics can influence players’ moves, as decisions are now driven not only by traditional chess strategies but also by the potential to gain valuable tokens, making the game more engaging.

How it's Made

The chess game project is implemented using “dojoengine” in Cairo, with main contract/provable components detailed in 'board.cairo' and 'action.cairo' files. The front-end builds upon the boot-camp repository showcased during the Starthack video presentation for dojoengine and using the "@dojoengine/react-recs-core-utils" libraries (see the client folder).

The front-end is connects the Cairo contracts deployed to both local and publicly available Katana and Torii instances, utilizing Slot. Here the public RPC:

There are two main Cairo contracts: 'board.cairo' and 'actions.cairo'. The board contract contains all the required models. The ``'Board' model represents a game state (hardcoded with id 1), with variables indicating the players’ addresses, the current turn (a boolean, false for white and true for black), and whether the game has started (is_started), which means that the players have already assigned their tokens to the pieces, or if it has finished and who the winner is. The chessboard is modeled as a list of 'Cell' entities, where each cell’s value represents a chess piece using FEN notation. The value field is a 'Type' enum where each item is a piece type according to the FEN notation, e.g., PAWN (capital letter for white) and bishop (lowercase for black pieces, for example, the black bishop). These representations make it easier to get the FEN string that can be used as input for chess engines and rendering libraries like the npm 'chess.js' and 'react-chessboard'. Finally, there are two simple implementations for 'ERC20' and 'ERC721' token models.

The 'actions.cairo' contract is responsible for checking and updating the states of the models.

The 'spawn method', initializes the chessboard, allocates mock NFTs and tokens to the two players (black and white), and checks the game state—verifying if it has started, if tokens have been assigned to pieces, and if the game has concluded with a winner.

The 'ride_piece' and 'assign_tokens' actions can only be called if the chess game has not started and ensures that the tokens belong to the calling player, checking balances, and confirming the correct piece color for assigning tokens to pieces.

The start_game method is called after assigning tokens and allows the chess game to start.

The move_piece method can only be called after the game has started, checking if it is the calling player’s turn and enforcing traditional chess rules, such as a bishop moving diagonally or a knight in an L-shape (see cheks rules in the end of this section). Additionally, if a piece with tokens is captured, the assigned tokens are instantly transferred to the capturing player. Finally, it also checks if the captured piece was the king, and in that case, assigns 10,000 tokens to the winner and gives back the non-captured NFTs, and sets the game to finish.


  • Useful queries to get the provable state of the game here in this Readme section

  • Longer video version with Graphql playground deep-dive : youtube URL

  • The shorter version within 4 minutes: youtube URL

Example of allowed moves for a piece using the array (FEN) notation, where the entire chessboard is represented as an array. Please note that these checks have not been fully tested and require additional testing:

background image mobile

Join the mailing list

Get the latest news and updates