Intercom

Example App: intercom/ (Built on trac-peer)

intercom/ (in this workspace) is a reference “real app” built on top of trac-peer.

It demonstrates how a team can ship a custom subnet runtime by composing:

  • a Protocol (contract/protocol.js) — command parsing + custom CLI commands

  • a Contract (contract/contract.js) — deterministic state machine

  • Features (features/*) — optional side processes (oracles / integrations), e.g. sidechannels

  • a Runner (index.js) — wires MSB + peer + features and starts the terminal

If you’re looking for “what does an actual app repo look like?”, start here.

What you get by running Intercom

When you run Intercom, you are running:

  1. an MSB node (in-process, non-interactive)

  2. a trac-peer subnet node on top of it

  3. Intercom features (notably sidechannels for fast P2P messaging)

  4. an interactive terminal

Intercom is especially useful for testing:

  • multi-peer subnet creation/joining

  • writer gating (admin approves writers) vs open app mode (auto-add writers)

  • sidechannels (fast ephemeral P2P messaging alongside the contract layer)

Install + prerequisites

From the workspace root:

Intercom is intended to run under Pear:

Create a new Intercom app subnet (admin peer)

Pick a subnet channel name (this is the “app name” / rendezvous string):

On startup, Intercom prints:

  • Peer subnet bootstrap: <hex32> — share this with joiners (it’s also persisted to stores/admin/subnet-bootstrap.hex)

  • Peer writer key (hex): <hex32> — admin’s writer key

  • MSB network bootstrap: <hex32> + MSB channel: <string> — Intercom’s MSB network identifiers for this run

Notes:

  • In Intercom, the admin positional argument is a store label and becomes the default --peer-store-name.

  • Intercom starts its own MSB node by default (so you get a self-contained dev network). If you want it to join an existing external MSB network, Intercom’s runner would need to accept and pass MSB bootstrap/channel (Intercom currently doesn’t expose those flags in index.js).

Start joiners (alice + bob)

Use the admin’s subnet bootstrap and the same subnet channel:

Each joiner will print its own writer key.

Writer gating vs open apps

Gated (default): admin approves writers

On the admin peer:

Open: auto-add writers

On the admin peer:

Sidechannels (fast P2P messaging)

Intercom includes a sidechannel system for low-latency, ephemeral messaging (not settled, not persisted like contract state).

Join a channel:

Send a message:

Inspect:

Where to look in code (Intercom repo)

Intercom’s own guide:

Last updated