This app runs a P2P chat contract where a single shared AI agent responds publicly when tagged with @ai. The AI is backed by a local REST model endpoint at the bootstrap's Oracle (Chat Completions API). The contract enforces ordered processing of messages and per-user rate limits.
Mac/Linux/Windows, Node.js 22+, Git.
Quick per‑OS setup:
macOS
- Install Xcode Command Line Tools:
xcode-select --install - Install Node.js 22 (pick one):
- Homebrew:
brew install node@22 && echo 'export PATH="/opt/homebrew/opt/node@22/bin:$PATH"' >> ~/.zshrc - NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashthennvm install 22 && nvm use 22
- Homebrew:
- Install Git:
brew install git(Git may already be available)
Ubuntu/Debian
- Tools:
sudo apt update && sudo apt install -y git curl build-essential - Install Node.js 22 (pick one):
- NodeSource:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt install -y nodejs - NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashthennvm install 22 && nvm use 22
- NodeSource:
Fedora/CentOS/RHEL
- Tools:
sudo dnf install -y git gcc-c++ make curl - Install Node.js 22 (pick one):
- NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashthennvm install 22 && nvm use 22
- NVM:
Windows 10/11
- Git:
winget install Git.Git(or install from git-scm.com) - Node.js 22 (pick one):
- NVM for Windows:
winget install CoreyButler.NVMforWindows, then runnvm install 22andnvm use 22 - Installer from nodejs.org (Current 22.x)
- NVM for Windows:
- Optional build tools (only if native modules need to compile):
winget install Microsoft.VisualStudio.2022.BuildToolsand select C++ build tools
Clone the repo, change into it, then install the CLI and deps:
git clone https://github.com/Trac-Systems/trac-ai-chat-example.git
cd trac-ai-chat-example
# Install Pear (App3 runtime) globally
npm install -g pear
# Install project dependencies
npm installpear run . store1Wait for the terminal/app to fully load before you try prompting (may take a while).
By default, the app starts in desktop mode. To run it in terminal mode, edit the package.json file and replace index.js with index.html and terminal with desktop.
In the terminal type your message like this:
/post --message "hi"To talk to the ai directly, tag it with @ai:
/post --message "@ai hi"The ai will tag your with your nickname or your publickey if the nickname isn't set yet.
To change your nickname, do this:
/set_nick --nick "Peter"-
Bootstrap an MSB and Peer per Trac docs. In
index.js, set the Peerbootstrapandchannelfor your contract. The MSB config points to a public testnet by default. -
Run the app, choose a wallet seed (interactive), then add yourself as admin in the terminal:
/add_admin --address <YourPeerWriterAddress>
- Ensure chat is enabled and, if desired, auto-add writers:
/set_chat --enabled 1
/set_auto_add_writers --enabled 1
-
Start your local model API e.g. at
http://127.0.0.1:8000/v1/chat/completions. -
Use the terminal chat; mention
@aifollowed by your prompt. The AI will reply in public if you’re within rate limits.