{"id":13570722,"url":"https://github.com/greenlucid/chess-cairo","last_synced_at":"2026-01-18T10:02:20.410Z","repository":{"id":38011491,"uuid":"441955466","full_name":"greenlucid/chess-cairo","owner":"greenlucid","description":"A Cairo contract to play chess in Starknet.","archived":false,"fork":false,"pushed_at":"2022-12-26T18:54:26.000Z","size":327,"stargazers_count":38,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T23:31:07.311Z","etag":null,"topics":["cairo","cairo-lang","chess","starknet"],"latest_commit_sha":null,"homepage":"","language":"Cairo","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greenlucid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-26T18:13:58.000Z","updated_at":"2024-11-20T18:29:40.000Z","dependencies_parsed_at":"2023-01-31T01:00:30.497Z","dependency_job_id":null,"html_url":"https://github.com/greenlucid/chess-cairo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/greenlucid/chess-cairo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenlucid%2Fchess-cairo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenlucid%2Fchess-cairo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenlucid%2Fchess-cairo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenlucid%2Fchess-cairo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greenlucid","download_url":"https://codeload.github.com/greenlucid/chess-cairo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenlucid%2Fchess-cairo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cairo","cairo-lang","chess","starknet"],"created_at":"2024-08-01T14:00:54.494Z","updated_at":"2026-01-18T10:02:20.375Z","avatar_url":"https://github.com/greenlucid.png","language":"Cairo","funding_links":[],"categories":["Applications","Uncategorized"],"sub_categories":["Games","Uncategorized"],"readme":"# chess.cairo\n\nA Cairo contract to play chess, with composability in mind.\n\n##  How it works\n\nEvery game of chess will be deployed in a single contract. Each contract has who plays as white, as black, who is the governor, and the initial fen state.\n\n## State of chess\n\nBecause of threefold repetition, the full state of chess requires the full history of moves, so that any of the players can force a draw if a board state is reached three times. A **board state** is what is commonly referred to as the \"state\" of chess. That is, whatever can be represented with [Forsyth–Edwards Notation](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation), except the fullmove clock and the **halfmove clock** (count of plys since last irreversible action).\n\n### Glossary of *states*\n\n- **board state**: positions, active color, castling rights, passant.\n- **fen state**: board state \u0026 halfmove clock \u0026 fullmove clock.\n- **full state**: board state \u0026 halfmove clock \u0026 move history.\n\n## How the state is stored\n\nIn chess.cairo, the contract keeps `initial_state`, an encoded fen state, and `moves`, the array of moves. That means, the contract effectively holds the full state. You can reach the current fen state by iterating through the move history, advancing move by move.\n\n# Installation\n\nThis project uses [nile](https://github.com/OpenZeppelin/nile). Refer to it if you're lost. You'll also need pyenv, to use python3.7.\n\n- `python3.7 -m venv env`\n- `source env/bin/activate`\n- `pip install git+https://github.com/OpenZeppelin/nile.git#egg=cairo-nile`\n- `echo \"WHITE=1234\" \u003e .env`\n\n## Running it\n\nGo to notes/useful_commands.txt to find some stuff. `{}` means you paste an address or a big hex.\n\n- `source env/bin/activate` (do this in 2 terminals)\n- `nile node`\n- `nile setup WHITE`\n- `nile compile contracts/chess.cairo`\n- `nile deploy chess {white} {white} {white} {initial_fen}`\n- `nile send WHITE {chess} make_move 13456 0`\n\nIf you got here you can figure out the rest yourself\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreenlucid%2Fchess-cairo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreenlucid%2Fchess-cairo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreenlucid%2Fchess-cairo/lists"}