Code Monkey home page Code Monkey logo

ethchess's Introduction

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing

โ™˜ ETHChess

Decentralized Chess app allowing p2p wagered matches and deathmatch competitions
Link to test site

ETH-Chess enables decentralized 1v1 chess matches between random or specific opponents,
as well as competitive DeathMatch tournaments where the player that wins 3 consecutive match rounds, wins the Rewards Pot!

Custom Solidity contracts for p2p wagered matches

EthChessMatches.sol allows for 1v1 random or specific chess matches or DeathMatch tournaments.

EthChessNFTs.sol allows for rewarded dispute resolution processes.


Chess Matches

1.) Matches are initiated with a wager amount specified by the player.

2.) Competitors start the Match by entering the equivalent wager amount,
plus the hash of the IPFS object containing Match details and first move.

3.) The winner of the Match enters a winning claim with the final game state IPFS hash and a security deposit equal to the initial wager.

4a.) The opponent has a dispute claim period of n blocks(where n is an adjustable amount initially set at 7)
to enter their IPFS hash and a security deposit equal to twice the amount of the initial wager.
4b.) If disputed, up to 20 EthChess NFT holders can vote on the dispute, 10 for initial Claim is True, 10 for initial Claim is False(Dispute is true).
4c) If the amount of True votes is >= False votes(benefit of the doubt is favored to the claimant),
then the claimant wins the Match total + their initial Claim security deposit back - n fee(where n is an adjustable fee set at 10% that goes to the DeathMatch rewards pot).
Each voter that voted True receives (1/2 of the Dispute security deposit / amount of True voters).
The other 1/2 of the Dispute security deposit goes to the DeathMatch rewards pot.
If the Dispute is True, the disputer wins the Match total + their initial Dispute security deposit - n fee(where n is an adjustable fee set at 10% that goes to the DeathMatch rewards pot).
Each voter that voted False receives ( Claim security deposit / amount of False voters).

*The voters in the dispute resolution process receives the same amount of rewards whicever way they vote.
1/2 of Dispute security deposit == Claim security deposit
The only difference is if the Dispute is false, half of the security contributes to the DeathMatch rewards pot.*


Chess DeathMatches

DeathMatches consists of rounds containing Match structs and a reigning champion.
1.) Player initiates DeathMatch with round wager amount.
Each player must enter this amount each round.
2.) Opponent starts DeathMatch round by cycling through the Matches claim/dispute resolution process.
3.) Match winners can advance the DeathMatch round, starting a new Match.
Match rewards are accumulated in the DeathMatch rewards pot.
4.) The Reigning Champion that wins 3 Rounds in a row wins the DeathMatch rewards pot + (platform rewards pot / n (where n is an adjustable fee set at 50%))


Technologies Used

IPFS

IPFS-http-client Github Repo IPFS-http-client is used for storage and content-addressing services.

Each on-chain Match gameplay state is preserved with each move to IPFS, and each previous hash appended to the next IPFS object.

Each player will have a chain of IPFS CID's that can be submitted at the end of the match, either to cliam vicotry or to dispute the results.

This allows for an immutable chain of events that contributes to the Dispute resolution process where holders of EthChess NFTs an vote on the outcome by reviewing the IPFS CID chained history.

Link to IPFS instance hook.
Link to usage.
Link to usage

Gun.js

Gun.js is used in both the frontend and the backend applications for decentralized storage and cryptographic verification processes for user profiles.


**GUN** is an [ecosystem](https://gun.eco/docs/Ecosystem) of **tools** that let you build [community run](https://www.nbcnews.com/tech/tech-news/these-technologists-think-internet-broken-so-they-re-building-another-n1030136) and [encrypted applications](https://gun.eco/docs/Cartoon-Cryptography) - like an Open Source Firebase or a Decentralized Dropbox.

The Internet Archive and 100s of other apps run GUN in-production. GUN is also part of Twitter's Bluesky initiative!

  • Multiplayer by default with realtime p2p state synchronization!
  • Graph data lets you use key/value, tables, documents, videos, & more!
  • Local-first, offline, and decentralized with end-to-end encryption.

About

First & foremost, GUN is **a community of the nicest and most helpful people** out there. So [I want to invite you](http://chat.gun.eco) to come tell us about what **you** are working on & wanting to build (new or old school alike! Just be nice as well.) and ask us your questions directly. :)


Watch the 100 second intro!

The GUN ecosystem stack is a collection of independent and modular tools covering everything from CRDT conflict resolution, cryptographic security & encryption, radix storage serialization, mesh networking & routing algorithms, to distributed systems correctness & load testing, CPU scheduled JSON parser to prevent UI lag, and more!

Chess.js

Chess.js Github Repo

chess.js is a Javascript chess library that is used for chess move generation/validation, piece placement/movement,
and check/checkmate/stalemate detection - basically everything but the AI.

ChessGround

ChessGround Github Repo

Chessground is a free/libre open source chess UI developed for lichess.org. It targets modern browsers, as well as mobile development using Cordova.

This project code has been made public in condition with this repo GPL-3.0 license.


๐Ÿ— Scaffold-ETH

Scaffold-Eth GitHub repo

CRA platform scaffolded using Scaffold-ETH(more info found below)

everything you need to build on Ethereum! ๐Ÿš€

๐Ÿงช Quickly experiment with Solidity using a frontend that adapts to your smart contract:

image

Documentation, tutorials, challenges, and many more resources, visit: docs.scaffoldeth.io

๐Ÿฆ Other Flavors


๐Ÿ„โ€โ™‚๏ธ ETH-Chess Quick Start

Prerequisites: Node (v16 LTS) plus Yarn and Git

clone/fork โ™ž EthChess:

git clone https://github.com/StarKeyJON/EthChess.git

install and start your ๐Ÿ‘ทโ€ Hardhat chain:

cd EthChess
yarn install
yarn chain

in a second terminal window, start your ๐Ÿ—„๏ธ server:

cd EthChess
yarn server

in a third terminal window, start your ๐Ÿ“ฑ frontend:

cd EthChess
yarn start

in a fourth terminal window, ๐Ÿ›ฐ deploy your contract:

cd EthChess
yarn deploy

...

๐Ÿ’Œ P.S

๐Ÿ”‘ You need to create a .env file for packages/server from the example.env, file as well as in packages/react-app. If you would like to persist data to s3 storage, place in your s3 bucket details to enable gun.js s3, and uncomment the s3 imports in packages/server/config.js .

๐ŸŒ You need an RPC key for testnets and production deployments, create an Alchemy account and replace the value of ALCHEMY_KEY = xxx in packages/react-app/src/constants.js with your new key.

๐Ÿ“ฃ Make sure you update the InfuraID before you go to production. Huge thanks to Infura for our special account that fields 7m req/day!


Automated with Gitpod

Open in Gitpod

Roadmap

  • Add README
  • Solidity
    • Develop EthChess Matches Contract
    • Develop EthChess NFT Contract
    • Unit tests for smart contracts
      • Statements Coverage > 90%
      • Branch Coverage > 90%
      • Function Coverage > 90%
      • Lines Coverage > 90%
    • Develop secondary contracts
      • EthChess Leagues
      • EthChess Tournaments
      • EthChess Treasury
  • The Graph
    • Develop mono subgraph
    • refactor subgraph against final contracts
  • Front-End
    • App
    • Home
    • Lobby
      • P vs. Comp Skirmish
      • PvP Skirmish
      • Wagered Match
      • Wagered DeathMatch
    • Voting
    • Mint
    • Info
  • Back-End
    • Express server
    • Gun.js relay node

See the ISSUE TEMPLATE for how to propose features and issues.

(back to top)

ethchess's People

Contributors

starkeyjon avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

junaidookay

ethchess's Issues

Design & Implementation

The current design utilizes chess.js along with a lichess chessboard for gameplay activity.

This design takes a singular authority approach where a server is needed to maintain user authorization, historical data, data integrity, move validation and more. This brings a challenge of security and maintenance, as well as cultivating the trust and adoption of a new chess platform.

A new approach would be utilizing existing chess platform public api's to integrate the ETHChess framework as a standalone plugin. Users would then be able to integrate their public profiles and utilize the platform gameplay of their choice. The scope of gameplay authorization and validation would rely on their trusted platform of choice, and a recording of events would them be memorialized with IPFS and submitted to the blockchain for the claim dispute resolution process.

Guide to make it work in 2024?

Like the title say "A step by step setup guide to make it work in 2024?". It would be great if you can introduce a step by step guide for beginners to setup this project locally in 2024.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.