Intercom
Example App: intercom/ (Built on trac-peer)
intercom/ is a reference “real app” built on top of the trac-peer runtime.
It’s useful if you want to see what a production-ish subnet app repo looks like: a runner that boots MSB + peer, a contract/protocol pair, and a couple of optional features (sidechannels, timer).
What Intercom demonstrates
How to ship an app: a repo that depends on
trac-peerand wires upProtocol + Contract + Features.How to run multi-peer subnets: bootstrap an “app network”, then join more peers.
Roles: admin, writers, and indexers (durability vs cost/ops).
Sidechannels: fast, ephemeral P2P messaging alongside the contract state machine.
Get Intercom
Clone the repo:
git clone https://github.com/Trac-Systems/intercomPrerequisites
Node.js: Intercom is intended to run on Node 22+ (prefer 22/23; avoid 24 if you hit Pear/native issues).
Pear runtime:
Install
For full Intercom operational guidance (first-run decisions, security defaults, etc.), also read ../intercom/SKILL.md.
Create a new Intercom subnet (bootstrap / admin peer)
Pick a subnet channel name (this is the app’s rendezvous string) and start the first peer:
On startup, Intercom prints the important bits you’ll need later:
Peer subnet bootstrap: <hex32>— share this with joiners (also persisted tostores/admin/subnet-bootstrap.hex)Peer pubkey (hex): <hex32>— this is the admin peer’s public key (used for/add_admin)Peer writer key (hex): <hex32>— the admin peer’s writer key (used for/add_writer//add_indexer)MSB network bootstrap: <hex32>+MSB channel: <string>— the embedded MSB node identifiers Intercom is using
First-time admin setup (required on new subnets)
On a brand-new subnet, you must set the subnet admin once, on the bootstrap node:
Verify:
Start joiners (alice + bob)
Joiners must use the same subnet channel and the bootstrap’s subnet bootstrap hex:
Each joiner prints its own:
Peer pubkey (hex)(identity)Peer writer key (hex)(what the admin approves as writer/indexer)
Writers and indexers (recommended guidance)
Intercom itself is a non-financial app example. Rule of thumb:
Non-financial apps: 1 indexer can be enough.
Financial / “value” apps: run 3 indexers, ideally operated by different parties and in different locations.
The first indexer is usually the admin peer.
Gated (default): admin approves writers/indexers
On the admin peer:
To make a peer an indexer (durable availability for reads / indexing):
Open apps: auto-add writers
On the admin peer:
Sidechannels (fast P2P messaging)
Intercom always joins the entry channel:
You can join additional channels at runtime:
Send:
Inspect:
Sidechannel flags supported by Intercom’s runner
Intercom’s index.js supports (via flags or env):
--sidechannels "a,b,c"(or--sidechannel "a,b,c") — join extra channels at startup (entry channel is always joined)--sidechannel-debug 1— verbose logs--sidechannel-max-bytes <n>— payload size guard--sidechannel-allow-remote-open 0|1— accept/reject remote open requests (default: on)--sidechannel-auto-join 0|1— auto-join requested channels (default: off)
Example:
RPC (wallet / dApp connectivity)
Intercom is a terminal-first reference app. Its runner (../intercom/index.js) starts the interactive terminal and sidechannels, but it does not expose the trac-peer HTTP RPC server by default.
If you want an app that wallets/dApps can talk to over HTTP:
follow the
trac-peerRPC docs (docs/04-rpc.md,docs/16-peer-rpc-reference.md)add RPC wiring to your app runner (similar to how
trac-peer/scripts/run-peer.mjsdoes it)
Using your local trac-peer/ checkout (optional, for contributors)
Intercom pins trac-peer by commit. If you want Intercom to use your local trac-peer/ checkout while developing:
Edit
../intercom/package.json:change the
trac-peerdependency tofile:../trac-peer
Reinstall:
Where to look in code (Intercom repo)
Runner:
intercom/index.jsProtocol:
intercom/contract/protocol.jsContract:
intercom/contract/contract.jsSidechannels:
intercom/features/sidechannel/index.jsTimer feature example:
intercom/features/timer/index.js
Intercom’s own guide:
Last updated