> 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/msb-local-setup.md).

# MSB Local setup

This page explains how to run and operate an **MSB (Main Settlement Bus)** node locally so you can:

* fund accounts (peer MSB addresses + wallet MSB addresses)
* deploy/check subnet registrations
* inspect txs and debug settlement

It does **not** modify the MSB repo; it only documents how to use it.

***

### 0) Glossary (quick)

* **bootstrap**: 32-byte hex id (64 hex chars) identifying the MSB Autobase.
* **channel**: discovery topic (string) that MSB nodes must share to find each other.
* **store**: local persisted data for one node (usually `stores/<name>/...`).
* **MSB address**: bech32m address like `trac1...`.
* **fee**: MSB-level fee required to broadcast a transaction.
* **confirmed vs unconfirmed** (MSB): confirmed = signed state, unconfirmed = local unsigned view.

***

### 1) Prereqs

* Node.js + npm
* Pear (MSB scripts typically use Pear)

```sh
npm install -g pear
pear -v
```

Optional (if you run MSB tests):

```sh
npm install -g bare
```

***

### 2) Install MSB repo

From your workspace root:

```sh
git clone -b main --single-branch git@github.com:Trac-Systems/main_settlement_bus.git
cd main_settlement_bus
npm install
```

***

### 3) Run MSB locally

#### 3.1 Interactive CLI node (recommended)

```sh
MSB_STORE=node1 npm run env-prod
```

This starts an interactive MSB node and stores data under `main_settlement_bus/stores/node1/`.

#### 3.2 RPC node (optional)

```sh
MSB_STORE=rpc-node-store MSB_HOST=127.0.0.1 MSB_PORT=5000 npm run env-prod-rpc
```

***

### 4) Admin mode (if you need whitelisting/init)

MSB has extra admin-only commands (whitelisting, initialization migrations, banning). In the current MSB codebase, admin mode is inferred by store name:

```sh
MSB_STORE=admin npm run env-prod
```

***

### 5) MSB commands you’ll use most

Inside the MSB terminal, run `/help` for the full list. Common ones:

#### Network/state inspection

* `/stats`
* `/confirmed_length`
* `/unconfirmed_length`
* `/get_fee`
* `/get_txv`

#### Account inspection

* `/get_balance <address> <confirmed>` (confirmed defaults to `true`)
* `/node_status <address>`

#### Funding (critical for `trac-peer`)

To make an address “exist” in MSB state and have fee balance:

```txt
/transfer <to_address> <amount>
```

You must fund:

* each **peer’s** printed `Peer MSB address` (peer node operations)
* each **wallet user** MSB address (the requester) that will sign contract txs

If you don’t, you’ll see errors like:

* `Requester address not found in state`
* insufficient fee balance

#### Subnet deployment entries (for `trac-peer`)

* `/deployment <subnet_bootstrap_hex32> <channel>`
* `/get_deployment <subnet_bootstrap_hex32>`

#### Tx lookup / debugging

* `/get_tx_info <tx_hash>`
* `/get_tx_details <tx_hash>`
* `/get_extended_tx_details <tx_hash> <confirmed>`
* `/get_txs_hashes <start> <end>`

***

### 6) Whitelisting + initial balances (optional bootstrap workflow)

MSB supports an initialization phase that reads from files:

* `main_settlement_bus/migration/initial_balances.csv`
* `main_settlement_bus/whitelist/addresses.csv`

In an MSB admin terminal you can run:

* `/balance_migration`
* `/add_whitelist`
* `/disable_initialization`

***

### 7) Next: run `trac-peer`

Once MSB is running and you know:

* `MSB_BOOTSTRAP`
* `MSB_CHANNEL`

continue with:

* &#x20;[Bootstrap checklist](/documentation/developers/mainnet/dapp-developer-guide/bootstrap-checklist.md) (canonical A→Z checklist)


---

# 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/msb-local-setup.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.
