CryptoChess is a dApp on the Flare network that allows players to compete for crypto prizes by linking smart contracts to tournaments on chess.com. It leverages the Flare Data Connector (FDC) to verify data from the chess.com API, such as the players participating in the tournament, the tournament status and the winner of the tournament.
The current development build is live at crypto-chess-flare.vercel.app.
You can see a demonstration video of the dApp here.
-
The tournament organizer creates a tournament on chess.com and invites players to join.
-
From the CryptoChess frontend the tournament organizer deploys a smart contract with the chess.com url of the tournament and a chosen participation fee as arguments. The frontend calls the createTournament function on the ChessTournament factory contract which deploys a clone of the ChessTournament implementation contract, with the arguments provided by the tournament organizer. See the diagram below:
- Players select the tournament from the list on the frontend and join by submitting their chess.com username and paying the participation fee. This will send a request to the backend server to submit an attestation request and retrieve a proof from the Flare DA layer to verify that the username submitted is indeed part of the tournament on chess.com. This proof is sent back to the frontend and provided as argument to the addPlayer function on the tournament contract, which upon verification will receive the payment and map the player's username to their wallet address.
-
When all players have paid the participation fee, the players play the tournament on chess.com.
-
After the tournament is finished, anyone can trigger the "Send Prize" button on the frontend, which sends a request to the backend to submit an attestation request and retrieve a proof from the Flare DA layer to verify the tournament status and winner. This proof is sent back to the frontend and provided as argument for the finishTournament function on the tournament contract. If the proof is valid, the prize money in the contract (the total amount of participation fees paid by the players) is sent to the address mapped to the winner's username.
*Please note that the chess.com API can take up to 12 hours to update all it's data. Which can result in the tournament being finished, but the 'Send Prize' button not being available yet.
This project consists of 3 parts: webapp, server and contracts. Run the server first, then the webapp. You won't need to go into contracts, unless you want to deploy your own modified versions of the ChessTournament smart contracts.
This project requires Node.js 18.17.0 or newer.
Go into the server folder:
cd server
Copy the .env.example file into your local .env file.
cp .env.example .env
Don't forget to add your PRIVATE_KEY.
Then install dependencies and run the server:
npm install
npx run start
Go into the webapp folder:
cd webapp
Copy the .env.example file into your local .env file.
cp .env.example .env
Don't forget to add your API keys for FLARE_API_KEY_TESTNET JQ_VERIFIER_API_KEY_TESTNET.
Then install dependencies and run the webapp:
npm install
npm run dev


