# Quickstart

## Local Dev

Goal: connect `trac-peer` to an already-running MSB network, create/join a subnet, and execute one demo contract operation.

### Prereqs

* Node.js + npm
* MSB network parameters:
  * `MSB_BOOTSTRAP`: 32-byte hex (64 hex chars)
  * `MSB_CHANNEL`: string
* An MSB “admin/funded” node that can transfer TNK to new addresses (so new peers can pay MSB fees).

### 1) Install

From the `trac-peer` repo folder:

```sh
npm install
```

### 2) Start the first peer (creates a new subnet)

This starts an in-process MSB *client node* (joins your MSB network) + the subnet peer node.

```sh
npm run peer:run -- \
  --msb-bootstrap=<MSB_BOOTSTRAP_HEX32> \
  --msb-channel=<MSB_CHANNEL> \
  --msb-store-name=peer-msb-1 \
  --peer-store-name=peer1 \
  --subnet-channel=tuxedex-v1
```

On first run, the peer will generate a **subnet bootstrap** and persist it to:

* `stores/peer1/subnet-bootstrap.hex`

Share that hex with joiners.

### 3) Fund the peer on MSB

In the peer logs you’ll see:

* `Peer MSB address: trac1...`

On your MSB funded/admin node, transfer TNK to that address (any amount that covers fees for a few txs).

Why: MSB rejects txs from addresses that don’t exist in MSB state or can’t pay fees.

### 4) Deploy the subnet (one-time per subnet)

In the peer terminal:

```txt
/deploy_subnet
```

This broadcasts an MSB operation that registers the subnet bootstrap + subnet channel.

### 5) Execute a demo contract operation

The default demo app is “Tuxemon”. It supports a single tx type:

* `catch`

In the peer terminal:

```txt
/tx --command "catch"
```

Then query your local subnet state:

```txt
/get --key app/tuxedex/<your-wallet-publicKey-hex> --confirmed false
```

You can print your pubkey via:

```txt
/stats
```

### 6) Start a second peer (join the existing subnet)

Use the subnet bootstrap from `stores/peer1/subnet-bootstrap.hex`.

```sh
npm run peer:run -- \
  --msb-bootstrap=<MSB_BOOTSTRAP_HEX32> \
  --msb-channel=<MSB_CHANNEL> \
  --msb-store-name=peer-msb-2 \
  --peer-store-name=peer2 \
  --subnet-channel=tuxedex-v1 \
  --subnet-bootstrap=<SUBNET_BOOTSTRAP_HEX32>
```

Fund `peer2`’s printed `Peer MSB address` the same way.

### Notes

* If you put flags on a new line without `\`, `zsh` will treat them as a new shell command.
* `confirmed=false` reads the local (unconfirmed) subnet view. `confirmed=true` reads the subnet’s signed view. These are subnet-specific, not “MSB finality”.
