Controller is a gaming specific smart contract wallet that enables seamless player onboarding and game interactions.
It supports transaction signing using Passkeys and Session Tokens.
The project consists of several subfolders located in the packages directory:
- keychain - a sandboxed application hosted at https://x.cartridge.gg/ and responsible for sensitive operations, such as signing transactions. When an application requests to sign or execute a transaction, keychain enforces client side authorization logic and displays UI for user approval if necessary.
- profile - a sandboxed application hosted at https://profile.cartridge.gg/ and responsible for displaying the state of Controller account, such as token balances, activities, and achievement.
- controller sdk. Controller implements the account interfaces required by starknet.js. Underneath, the implementation communicates with an embedded sandboxed keychain iframe.
Install pnpm via corepack:
corepack enable pnpmInstall dependencies:
pnpm iRun Controller with examples:
pnpm devThis command builds all workspace dependencies first and start these servers:
- http://localhost:3002: Controller Example (Next.js)
- http://localhost:5174: Controller Example (Svelte)
- http://localhost:3001: Keychain
- http://localhost:3003: Profile
The simplest way to then develop with your cartridge account is to port it over from the production keychain:
- Login to your account at https://x.cartridge.gg/login
- Open your console, dump your account with
window.cartridge.exportAccount()and copy it - Visting your local keychain at http://localhost:3001/
- Load your account into your local keychain
window.cartridge.importAccount("EXPORTED ACCOUNT");cargo install --git https://github.com/cartridge-gg/cainome --features="build-binary"To build rust you first have to compile cairo. Run
makein the root directory.
The compiled account is stored in the git repository in the
crates/account_sdk/artifacts/ folder. To make sure that the tests are run
against the most reacent version of the code run make in the root repository.
The make command should also be run before commiting any changes to ensure a
valid state of the compiled code.
Note, that to run the tests you first have to
compile (to sierra and casm) the contract in the
controller folder.
Starknet Foundry tests:
snforge test -p controllerScarb tests:
scarb test -p webauthn_*After the contract is compiled run the tests using cargo:
cargo testThe scarb builds the contract and saves the compiled code in the
controller/target folder. The tests then fetch (at compile time) the comipled
code and deploy it to the local network. Note that obviously the contract needs
to be recompiled for any changes to be applied in the compiled code.
