This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a PixeLAW App Template - a blockchain-based game development template built on the Starknet blockchain using the Dojo Framework. It creates interoperable pixel-based applications within the PixeLAW ecosystem.
Core Technologies:
- Cairo (v2.9.4) - Smart contract programming language for Starknet
- Dojo Framework (v1.5.1) - ECS (Entity Component System) framework for blockchain games
- Starknet - Layer 2 blockchain platform
- Scarb (v2.9.4) - Package manager and build tool for Cairo
# Build the project
sozo build
# Run tests
sozo test
# Build for Sepolia testnet
./scripts/build_sepolia.sh
# Deploy to local development environment
sozo migrate
# Deploy to Sepolia testnet
./scripts/deploy_sepolia.sh# Start local blockchain (Katana)
katana --dev
# Start indexing service (Torii)
torii --world <world_address>
# View logs in DevContainer
klog # Katana logs
tlog # Torii logs
slog # Server logs# Create keystore from private key (for testnet deployment)
./scripts/account_from_key.shThe project uses Dojo's Entity Component System (ECS) pattern:
- Entities: Represent game objects (pixels, players)
- Components: Data structures (ClickGame model, Pixel model)
- Systems: Logic that operates on components (myapp_actions)
- PixeLAW Core: Provides shared functionality via
pixelaw::core::actions - Interoperability: Apps can interact with pixels managed by other apps
- Namespace Separation:
pixelawnamespace for core,myappnamespace for app-specific logic
- src/app.cairo: Main application logic with ClickGame model and actions
- src/lib.cairo: Library entry point
- src/constants.cairo: App configuration (APP_KEY, APP_ICON)
- src/tests.cairo: Integration tests
- ClickGame Model: Tracks last player interaction per pixel position
- myapp_actions System: Handles pixel interaction logic
- Core Actions Integration: Uses PixeLAW core for pixel updates
- Use VSCode DevContainer (recommended) - all tools pre-installed
- Environment automatically starts Katana, Torii, and PixeLAW server
- Use built-in Katana accounts for testing
- Integration tests use mock world storage
- Tests deploy both core and app contracts
- Use
pixelaw_testinghelpers for setup - Example test in
src/tests.cairodemonstrates full interaction flow
- Development: Local Katana instance (
dojo_dev.toml) - Release: Production configuration (
dojo_release.toml) - Sepolia: Testnet deployment (
dojo_sepolia.toml)
- Use snake_case for variables and functions
- Use PascalCase for types and structs
- Follow Dojo's ECS patterns for components and systems
- Implement proper error handling with assertions
- Use Starknet-specific types (felt252, ContractAddress)
- Actions contracts:
{APP_KEY}_actions(e.g.,myapp_actions) - Models: Follow Dojo naming conventions
- Namespaces: Use app-specific namespace for custom logic
- Write integration tests for full user workflows
- Use
setup_core()helper for test environment - Test both successful and failure scenarios
- Verify pixel state changes after interactions
- pixelaw: PixeLAW core contracts (currently using local path)
- dojo: Dojo framework for ECS functionality
- dojo_cairo_test: Testing utilities
- pixelaw_testing: PixeLAW-specific test helpers
- Update version numbers in
Scarb.toml - Delete
/target/folder andScarb.lock - Run
sozo buildto rebuild - Fix any compilation issues
- Run
sozo testto verify tests pass - Deploy updates using
sozo migrate --profile sepolia
- Scarb.toml: Main package configuration and dependencies
- dojo_dev.toml: Local development environment settings
- dojo_sepolia.toml: Sepolia testnet deployment configuration
- .devcontainer/devcontainer.json: VSCode DevContainer setup
- The app integrates with PixeLAW core for pixel manipulation
- Multiple apps can interact with the same pixel world
- Use proper namespace management to avoid conflicts
- Always test locally before deploying to testnet
- Follow ECS patterns for clean separation of concerns