> For the complete documentation index, see [llms.txt](https://docs.trac.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trac.network/documentation/developers/mainnet/dapp-developer-guide/subnets-and-roles.md).

# Subnets and roles

## Subnets, Deployment, and Roles

This page explains how subnet registration works (MSB-side) and how admin/writer/indexer roles work (subnet-side).

### 1) Deploying a subnet (MSB registration)

Before contract txs can settle cleanly, the subnet must be registered in MSB.

On a running peer (typically the first node of the subnet), run:

```txt
/deploy_subnet
```

This broadcasts an MSB operation that registers:

* subnet bootstrap (`bs`)
* subnet channel (`ic` as a 32-byte identifier)

Peers can still replicate P2P without deploying, but MSB preflight checks and indexing behavior expect the subnet to exist in MSB state.

### 2) Admin role (subnet governance)

Subnet admin is stored inside the subnet state under:

* `admin`

On the bootstrap node, set the admin once:

```txt
/add_admin --address <peer-publicKey-hex>
```

Transfer admin later:

```txt
/update_admin --address <peer-publicKey-hex>
```

Verify:

```txt
/get --key admin --confirmed false
```

Notes:

* `--address` here is the **peer public key hex**, not a bech32 MSB address.

### 3) Writers vs indexers (Autobase roles)

Subnets use Autobase roles:

* **writers** can append subnet operations
* **indexers** participate in the linearization/indexing process (what advances the subnet’s signed/confirmed view)

#### Recommended indexer counts (rule of thumb)

How many peers you run depends on your application’s risk profile.

Rule of thumb:

* **Non-financial apps**: run **1 indexer**
* **Financial / “value” apps**: run **3 indexers**

For 3-indexer deployments, run them:

* in different datacenters/regions
* under different authorities/teams (if possible)

#### The first indexer is usually the admin

Operationally, the first node you bring up for a new subnet is typically:

* the subnet **admin** (governance)
* an **indexer** (so the subnet can actually produce confirmed state)

Admin commands:

```txt
/add_writer --key <writerKeyHex>
/remove_writer --key <writerKeyHex>

/add_indexer --key <writerKeyHex>
/remove_indexer --key <writerKeyHex>
```

Get your local writer key from:

```txt
/stats
```

### 4) Auto-add writers

Admins can allow nodes to become writers automatically when they join:

```txt
/set_auto_add_writers --enabled 1
```

This is subnet-scoped and only affects Autobase writer admission.

### 5) Transactions enabled switch

Subnets have a transactions gate:

* `txen` (transactions enabled)

Enable:

```txt
/enable_transactions
```

If disabled, subnet tx indexing and/or RPC tx submission will be blocked.

### 6) Chat system

The built-in chat system is off by default:

```txt
/set_chat_status --enabled 1
```

Post a message:

```txt
/post --message "hello"
```

Chat is a subnet feature. It does not move TNK; it only writes subnet state.

### 7) Confirmed vs unconfirmed subnet reads

When you query subnet state:

* `confirmed=false` reads the current local view (unsigned)
* `confirmed=true` reads the subnet’s signed view

These are properties of the subnet log/indexing, not “MSB settlement”.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.trac.network/documentation/developers/mainnet/dapp-developer-guide/subnets-and-roles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
