# Subnet Template CLI

### Built-in CLI Commands

The subnet template provides the following built-in CLI commands:

#### Bootnode & Bootnode API

Manages bootnode operations and API interactions.

The Bootnode API provides controlled access for frontends (e.g., scanners, stats dashboards) to query the subnet bootnode list and heartbeats (i.e, the DHT Records `"nodes"` key).

#### Example

```bash
subnet-dht-api \
--host_maddrs /ip4/0.0.0.0/tcp/31330 /ip4/0.0.0.0/udp/31330/quic \
--announce_maddrs /ip4/127.0.0.1/tcp/31330 /ip4/127.0.0.1/udp/31330/quic \
--identity_path {PRIVATE_KEY_PATH}
```

***

#### Run Node

Run a node with the server's minimal working example:

**Start DHT / Start Node**

This will start a new subnet (fresh swarm as initial node/bootnode and server in one)

```bash
subnet-server-mock \
--host_maddrs /ip4/0.0.0.0/tcp/31330 /ip4/0.0.0.0/udp/31330/quic \
--announce_maddrs /ip4/{your_ip}/tcp/31330 /ip4/{your_ip}/udp/31330/quic \
--identity_path bootnode.id \
--new_swarm  \
--subnet_id 1 --subnet_node_id 1
```

**Join DHT / Start Node**

```bash
subnet-server-mock \
--host_maddrs /ip4/0.0.0.0/tcp/31331 /ip4/0.0.0.0/udp/31331/quic \
--announce_maddrs /ip4/{your_ip}/tcp/31331 /ip4/{your_ip}/udp/31331/quic \
--identity_path alith.id \
--subnet_id 1 --subnet_node_id 2
```

***

#### Private Key Generation

Generates private keys for deterministic peer IDs.

> **Note:** This functionality is intended for in-subnet use only and should not be used for blockchain key generation.

#### Example

```bash
keygen \
--path test-ed25519.key \
--bootstrap_path test-b-ed25519.key \
--client_path test-c-ed25519.key \
--key_type ed25519
```

***

#### Blockchain Key Generation

Generates blockchain keys and outputs the following information:

* `mnemonic` – Recovery phrase for the key
* `private_key` – Private key value
* `account_id` – Account identifier (can be used as your hotkey or coldkey)

> **Security Warning:** If you use this command to generate keys, ensure you delete this data from your log history immediately after securely storing the credentials.

#### Example

```bash
generate-key --words 12
```

***

#### Subnet Management

Available to subnet owners:

* **Register** – Register a new subnet
* **Activate** – Activate a registered subnet

#### Example

```bash
register-subnet \
--max_cost 100.00 \
--name subnet-1 \
--repo github.com/subnet-1 \
--description "artificial intelligence" \
--misc "cool subnet" \
--min_stake 100.00 \
--max_stake  1000.00 \
--delegate_stake_percentage 0.1 \
--initial_coldkey 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac 1 \
--initial_coldkey 0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0 1 \
--initial_coldkey 0x798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc 1 \
--initial_coldkey 0x773539d4Ac0e786233D90A233654ccEE26a613D9 1 \
--key_types "Rsa" \
--bootnodes /ip4/127.0.0.1/tcp/31330/p2p/QmShJYgxNoKn7xqdRQj5PBcNfPSsbWkgFBPA4mK5PH73JB
```

#### Example

```bash
activate-subnet --subnet_id 1
```

***

#### Subnet Validator Node

Manage validator node registration:

* **Register** – Register a validator node to the subnet
* **Remove** – Remove a validator node from the subnet

#### Example

```bash
register-node \
--subnet_id 1 \
--hotkey 0x773539d4Ac0e786233D90A233654ccEE26a613D9 \
--peer_id QmTJ8uyLJBwVprejUQfYFAywdXWfdnUQbC1Xif6QiTNta9 \
--bootnode_peer_id QmSjcNmhbRvek3YDQAAQ3rV8GKR8WByfW8LC4aMxk6gj7v \
--bootnode /ip4/127.00.1/tcp/31330/p2p/QmSjcNmhbRvek3YDQAAQ3rV8GKR8WByfW8LC4aMxk6gj7v \
--client_peer_id QmbRz8Bt1pMcVnUzVQpL2icveZz2MF7VtELC44v8kVNwiG \
--delegate_reward_rate 0.125 \
--stake_to_be_added 100.00
```

#### Example

```bash
remove-node \
--subnet_id 1 \
--subnet_node_id 1
```

***

### Adding Subnet-Specific CLI Commands

To extend the CLI with custom commands for your subnet:

1. **Create a command module:**
   * Navigate to the `subnet/subnet_cli/` directory
   * Create a new directory or file for your custom commands
2. **Register the command:**
   * Navigate to `setup.py` from the root directory
   * Locate the `setup()` function, then find the `entry_points` parameter
   * Add your subnet-specific commands to the `entry_points` configuration alongside the built-in CLI commands
