A game built on top of Dojo. See live example here
make build
This command compiles your project and prepares it for execution.
The Dojo Forkserver is a container that has the Katana RPC, the Torii World Indexer, and a Forkserver Dashboard. Once the container starts, it starts running Katana, deploys the World Container from the repo via the contracts volume (See the docker-compose.yml for more details), runs the post_deploy script from the repo's Scarb.toml, and starts up Torii. The Dojo Forkserver Dashboard is accesible via http://localhost:3000/fork.
make start_container
make prep_web
cd web
yarn
cd web
yarn dev
cd bots
yarn install
yarn dev
To change accounts, add an account query to the frontend url. For example: http://localhost:3000/?account=1. Add as many accounts as desired by following the pattern set in the env.example.
The following would be example players:
# for player 1
http://localhost:5173/?account=1
# for player 2
http://localhost:5173/?account=2
This is an overview of the most important folders/files:
Makefile
: A collection of helpful commands, mainly for Dojocontracts
: The Dojo Cairo smart contract code
src/components.cairo
: Dojo component definitionssrc/systems.cairo
: Dojo component definitionssrc/Scarb.toml
: The scarb config file used for katanaweb
: A Vite React project
.env
: (copied from env.example) Contains the hardcoded developer addresses used for Dojosrc/dojo/contractComponents.ts
: Client-side definitions of the componentssrc/dojo/createClientComponents.ts
: Client-side setup of the componentssrc/dojo/createSystemCalls.ts
: Client-side definitions of the systemssrc/systems.cairo
src/dojo/createSystemCalls.ts
src/components.cairo
src/dojo/contractComponents.ts
src/dojo/createClientComponents.ts
cd contracts && scarb run deploy
thread 'main' panicked at 'internal error: entered unreachable code:
Resolution: None, this is a know issue, can ignore
Resolution: Delete the contracts/target
dir
Register 2 accounts (example from https://github.com/coostendorp/dojo-rps):
let player1 = starknet::contract_address_const::<0x1337>();
let player2 = starknet::contract_address_const::<0x1338>();
And then switch accounts like this:
starknet::testing::set_contract_address(player1);