@chain-protocol/cli
v0.7.0
Published
The chain command: runs the SDK simulator for a Chain.wtf casino or PvP game in its own repository.
Readme
@chain-protocol/cli
The chain command for building Chain.wtf games in your own repository.
Start a game
npx @chain-protocol/cli init casino my-game
cd my-game
npm install
npm run dev # serves the game frontendIn a second terminal, start the SDK simulator:
npm run simulatorWith Bun, run bunx @chain-protocol/cli init casino my-game, bun install, bun run dev and
bun run simulator. Open the URL npm run simulator prints and play a round.
chain init
chain init <casino|pvp> [directory] [--template coinflip|bones|rps] creates a game from an
example: its frontend, its contract under contracts/src/ and the deployment.ts that names the
contract. package.json depends on the SDK and the CLI at ^ this CLI's version, so the game
takes their patch releases, and has a dev and a simulator script.
| Command | Creates |
| ----------------------------------------- | ------------------------------------------------------- |
| chain init casino my-game | The coinflip example. Frontend on port 3100. |
| chain init pvp my-game --template bones | The Bones example. Frontend on port 3200. |
| chain init pvp my-game --template rps | The Rock Paper Scissors example. Frontend on port 3500. |
- The directory defaults to the example's name. It must be missing or empty.
chain init pvpwithout--templateasks which example to use. Outside a terminal it exits 1 and asks for--template.- The package name in
package.jsonis the directory's name, lowercased.
chain dev
npx chain dev casino --frontend-url http://localhost:5173With Bun, run bunx chain dev casino --frontend-url http://localhost:5173.
chain dev casino (or chain dev pvp) starts the SDK simulator of the SDK your project
installed: the dev chain, the VRF node, the platform's contracts, the game your deployment.ts
names (redeployed when you save its contract) and the simulator page. Run it next to
deployment.ts. Open the URL it prints. The simulator page loads your game frontend from
--frontend-url. Press Ctrl-C to stop everything.
chain dev options
| Option | Default |
| ---------------- | ---------------------------------------------------------------------- |
| --frontend-url | http://localhost:5173 |
| --port | The simulator page port: casino 3300, pvp 3400. 0 picks a free port. |
| --rpc-port | The dev chain port: 8545 |
chain slots
chain slots builds a slot title with the slot engine of the casino SDK your project installed:
| Command | Does |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| chain slots compile <title.json> | Prints each bet configuration's exact figures. |
| chain slots check-mapping <title.json> | Checks the display mappings cover every prize. |
| chain slots deploy <title.json> --rpc <url> --deployer <address> | Deploys the title, naming --developer or the signer as its game developer. Signs with SLOT_ENGINE_PRIVATE_KEY. |
| chain slots decode <title address> --rpc <url> | Rebuilds tier lists and RTP from a live title's chain bytes. |
| chain slots import-stake <publish_files> --out <dir> | Converts a Stake Engine math export into a title. |
Run chain --help or chain <command> --help for the full list of flags.
Requirements
The CLI carries the dev chain, solc and the VRF node, so the SDK stays light. It needs Node 22+
or Bun 1.4.2+, and runs no install script. Its version moves with the SDKs: install the same
version of both. A breaking release publishes under the canary dist-tag first; install
@chain-protocol/cli@canary together with the SDK's canary.
