A peer-to-peer crypto contract network. Interacts with the Main Settlement Bus (MSB) to settle transactions.
Release 1 (R1) must be used alongside Trac Network R1 releases to maintain contract consistency.
Trac Peer is utilizing the Pear Runtime and Holepunch.
The project pins trac-msb 0.2.30 and requires bogon ^1.2.0 (the first release with isReserved). HyperDHT 6.29 or newer crashes with
isReserved is not a function during relayed same-host or LAN connections if it resolves bogon 1.1.0. This affects
plain peers too. postinstall checks every reachable HyperDHT copy, including nested ones, before applying the
existing version-checked Hypercore stall fix. A dependency's lockfile or overrides do not constrain consumers.
After an install with scripts disabled, run node node_modules/trac-peer/scripts/check-hyperdht-bogon.cjs, then
node node_modules/trac-peer/scripts/hypercore-stallfix/apply.mjs and repeat the latter with --check. Update the
application's lockfile if the check fails. npm run test:hyperdht-bogon exercises a local relay and two plain peers
on loopback ports 59100–59199 without joining any Trac network.
The package also pins compact-encoding 2.18.0, matching trac-msb. The older 2.16.1 pin lacks the IPv4/IPv6 address
encoders HyperDHT 6.29.6 uses, so a standalone trac-peer lockfile could fail a plain connection even with a fixed bogon.
git clone -b trac-peer-r1 --single-branch git@github.com:Trac-Systems/trac-peer.gitTrac Peer must be used in combination the MSB and a Protocol/Contract pair in a unified setup. Please check our repos for sample setups.
Docs:
DOCS.md— local MSB + peer setup, subnet workflow, RPC overviewAPP_DEV.md— build apps (Protocol + Contract), wallet/dapp integration, RPC tx flow
If you already have an MSB network running (same bootstrap + channel), you can start a local MSB node (new store) that joins that network, and run trac-peer on top of it (this runner uses the trac-msb package, so it does not require a local main_settlement_bus repo checkout).
This is currently required because trac-peer needs an in-process MSB instance to:
- broadcast
/deploy_subnet+/txpayloads, and - observe MSB confirmed state to decide when to execute subnet ops locally.
npm run peer:run -- --msb-bootstrap=<32-byte-hex> --msb-channel=<channel-string>Runs trac-peer through the Pear v2/v3 compatibility runner. With Pear v2 it delegates to the legacy
pear run command; with Pear v3 (where pear run was removed), or when no Pear platform version can be
detected, it starts the same entrypoint with the embedded pear-runtime module. The npm command and all
application flags are identical in both modes.
You can control stores via flags (recommended); an optional first positional arg can be used as a “store
label” fallback if --peer-store-name is omitted.
npm run peer:pear -- \
--msb-bootstrap=<32-byte-hex> \
--msb-channel=<channel-string> \
--msb-store-name=peer-msb-1 \
--peer-store-name=peer1Example (second node joining an existing subnet):
npm run peer:pear -- \
--msb-bootstrap=<32-byte-hex> \
--msb-channel=<channel-string> \
--msb-store-name=peer-msb-2 \
--peer-store-name=peer2 \
--subnet-bootstrap=<subnet-bootstrap-hex32>If you prefer multi-line in zsh, use \ line continuations:
npm run peer:run -- \
--msb-bootstrap <32-byte-hex> \
--msb-channel <channel-string> \
--msb-stores-directory stores \
--msb-store-name peer-msb-client \
--peer-stores-directory stores \
--peer-store-name subnet-peer \
--subnet-channel subnet-1The runner prints the Peer MSB address. Fund that address on MSB (so the node entry exists and fee checks pass), then in the peer console run:
/deploy_subnet/tx --command "ping hello"(dev protocol)- If you want to use admin-only commands (writer/indexer management, chat moderation), run
/add_admin --address "<peer-publicKey-hex>"and verify with/get --key admin --confirmed false.
Notes:
- The subnet bootstrap key is auto-generated the first time and persisted to
stores/<peer-store>/subnet-bootstrap.hex. - To start a fresh subnet, delete that file (and optionally the corresponding
stores/<peer-store>/directory). - To join an existing subnet explicitly, pass
--subnet-bootstrap <hex32>.
To run another peer on the same machine without clobbering the first one, use a different --peer-store-name (and a different --msb-store-name for the embedded MSB client node):
# peer 1 prints (or stores) its subnet bootstrap in: stores/peer/subnet-bootstrap.hex
npm run peer:run -- \
--msb-bootstrap <32-byte-hex> \
--msb-channel <channel-string> \
--msb-store-name peer-msb-2 \
--peer-store-name peer2 \
--subnet-bootstrap <subnet-bootstrap-hex32>You can start an HTTP API alongside the interactive peer.
This RPC is intended for wallet/dApp connectivity (URL + JSON), not for operating the peer node. Operator/admin actions remain CLI-only.
npm run peer:run -- \
--msb-bootstrap <32-byte-hex> \
--msb-channel <channel-string> \
--rpc \
--api-tx-exposed \
--rpc-host 127.0.0.1 \
--rpc-port 5001Endpoints (all JSON):
GET /v1/healthGET /v1/statusGET /v1/state?key=<hyperbee-key>&confirmed=true|falseGET /v1/contract/schema(JSON Schema; contract tx types + Protocol API methods)GET /v1/contract/noncePOST /v1/contract/tx/preparebody:{ "prepared_command": { "type": "...", "value": {} }, "address": "<pubkey-hex32>", "nonce": "<hex32>" }POST /v1/contract/txbody:{ "tx": "<hex32>", "prepared_command": { ... }, "address": "<pubkey-hex32>", "signature": "<hex64>", "nonce": "<hex32>", "sim": true|false }
Notes:
- To allow wallet tx submission, start the peer with
--rpcand--api-tx-exposed(or envPEER_API_TX_EXPOSED=1+PEER_RPC=1). - RPC request bodies are limited to
1_000_000bytes by default (override with--rpc-max-body-bytes).