{"id":19460152,"url":"https://github.com/offchainlabs/stylus-chess","last_synced_at":"2025-02-25T12:22:33.167Z","repository":{"id":223522302,"uuid":"760627054","full_name":"OffchainLabs/stylus-chess","owner":"OffchainLabs","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-26T21:25:47.000Z","size":370,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-08T02:18:20.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/OffchainLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"licenses/Apache-2.0","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-20T16:35:04.000Z","updated_at":"2024-07-17T20:21:49.000Z","dependencies_parsed_at":"2024-02-26T22:34:56.194Z","dependency_job_id":null,"html_url":"https://github.com/OffchainLabs/stylus-chess","commit_stats":null,"previous_names":["offchainlabs/stylus-chess"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OffchainLabs%2Fstylus-chess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OffchainLabs%2Fstylus-chess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OffchainLabs%2Fstylus-chess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OffchainLabs%2Fstylus-chess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OffchainLabs","download_url":"https://codeload.github.com/OffchainLabs/stylus-chess/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240664503,"owners_count":19837563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-10T17:35:45.830Z","updated_at":"2025-02-25T12:22:33.088Z","avatar_url":"https://github.com/OffchainLabs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Image](./header.png)\n\n# Stylus Chess\n\nDemonstrates the usage of an off-the-shelf chess engine from the Rust crates.io package registry to quickly build an onchain chess contract.\n\n## Requirements For Deployment\n\n- [Rust lang](https://www.rust-lang.org/tools/install)\n- [nitro testnode](https://docs.arbitrum.io/stylus/how-tos/local-stylus-dev-node) (requires docker)\n- [cargo stylus](https://docs.arbitrum.io/stylus/stylus-quickstart#creating-a-stylus-project)\n- [cast](https://book.getfoundry.sh/getting-started/installation) (part of the Foundry CLI suite)\n\n## ABI\n\n### `totalGames()(uint256)`\n\nReturns total number of games that have been created on this contract.\n\n`cast call --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"totalGames()(uint256)\" GAME_NUMBER_HERE`\n\n### `getTurnColor(uint256 game_number)(uint256)`\n\nGets the turn color for a given game number. Can either be 0 for WHITE or 1 for BLACK.\n\n`cast call --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"getTurnColor(uint256)(uint256)\" GAME_NUMBER_HERE`\n\n### `getCurrentPlayer(uint256 game_number)(address)`\n\nReturns the address of the current player who has next move for a given game number.\n\n`cast call --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"getCurrentPlayer(uint256)(address)\" GAME_NUMBER_HERE`\n\n### `playMove(uint256 game_number, uint256 from_row, uint256 from_col, uint256 to_row, uint256 to_col)(uint256)`\n\nAttempts to play a move for a given game number. Must pass in the current row and column for the piece and the desired row and column. Will return a status code for the attempted move, which will either be 1 for CONTINUING, 2 for ILLEGAL_MOVE, 3 for STALE_MATE or 4 for VICTORY.\n\nNOTE: This mutates state, so it must be written to the chain with a send.\n\n`cast send --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"playMove(uint256, uint256, uint256, uint256, uint256)(uint256)\" GAME_NUMBER_HERE FROM_ROW_HERE FROM_COL_HERE TO_ROW_HERE TO_COL_HERE`\n\n### `printGameState(uint256 game_number)`\n\nNOTE: This will only work locally and should be removed for any public testnet or mainnet.\n\nThis will print the state of the chess board to the Stylus console window when running an Arbitrum Nitro testnode locally. It uses unicode symbols to present an 8x8 grid in the console window.\n\n`cast call --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"printGameState(uint256)()\" GAME_NUMBER_HERE`\n\n### `boardStateByGameNumber(uint256 game_number)(uint256)`\n\nReturns the uint256 that represents the board state for a given game number.\n\n`cast call --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"boardStateByGameNumber(uint256)(uint256)\" GAME_NUMBER_HERE`\n\n### `createOrJoin()(uint256)`\n\nNOTE: This mutates state so it must be sent as an actual transaction.\n\nThis will either create a pending game to await a second player or will join the currently existing pending game.\n\n`cast send --rpc-url 'http://localhost:8547' --private-key PRIVATE_KEY_HERE DEPLOYMENT_ADDRESS_HERE \"createOrJoin()(uint256)\"`\n\n## Other Stylus Resources\n\n- [Stylus Rust SDK](https://docs.arbitrum.io/stylus/reference/rust-sdk-guide)\n- [Stylus By Example](https://arbitrum-stylus-by-example.vercel.app/basic_examples/hello_world)\n- [Awesome Stylus](https://github.com/OffchainLabs/awesome-stylus)\n- [Arbitrum Stylus Devs Telegram](https://t.me/arbitrum_stylus)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffchainlabs%2Fstylus-chess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foffchainlabs%2Fstylus-chess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffchainlabs%2Fstylus-chess/lists"}