Skip to main content

Synopsis

Where <network> is one of: local, dev, summit. Passing summit currently errors out with “Summit (mainnet) is not available yet” — included in the enum for forward compatibility. The optional --rpc-url flag overrides the default RPC URL for the network. This is useful when testing against a different validator instance or an ephemeral environment:

Behavior

  1. Create project directory structure:
cowboy init is safe to run multiple times — each run adds a new environment to .cowboy/config.json without overwriting keys. Starter actor scaffolding lives under cowboy actor new <name> and is not part of init.
  1. Generate a wallet — Calls the same logic as cowboy wallet create but targets .cowboy/keys/<network> instead of .cowboy/key. Each network gets its own key so you never accidentally sign a mainnet transaction with a local-only key.
  2. Write / merge network config — Reads any existing .cowboy/config.json, adds or updates the entry for <network>, and sets the active environment to the one just initialised. The new schema looks like:
    For dev, the CLI also writes the well-known watchtower_registry address so cowboy watchtower commands work without extra flags. Old flat-format configs ({ "network": "...", "rpc_url": "..." }) are migrated on first run.
  3. Auto-discover network identity (optional) — If a test/peers.yaml is present in the current directory or any ancestor, cowboy init extracts the BLS12-381 network identity and stores it as environments.<network>.identity so RAS / CBFS commands can verify chain artefacts without an extra flag.
  4. Fund the wallet (if faucet available) — For local and dev, sends POST <rpc_url>/faucet to fund the new wallet with CBY. Prints the funded amount and balance. If the faucet is unreachable, prints a warning and continues — the project is still usable.
  5. Print summary — Shows the created key path, config path, wallet address, and next steps.

Network Defaults

Example

Running cowboy init dev next adds dev to the same config without touching local:

Edge Cases

  • Existing key for the same network — If .cowboy/keys/<network> already exists, cowboy init <network> skips wallet generation and reuses the existing key. No overwrite ever happens.
  • Faucet unreachable — If the faucet request fails (network down, local validator not running), print a warning but continue. The project is still usable.
  • Old flat config format — If .cowboy/config.json uses the legacy { "network": "...", "rpc_url": "..." } schema, cowboy init migrates it in place to the environments schema on the next run.
  • summit network — Rejected with a clear error message; reserved for the future mainnet launch.

Testing