Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 20 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,31 @@
# Intercom
# Fractional Trading Cards (RWA) on Intercom

This repository is a reference implementation of the **Intercom** stack on Trac Network for an **internet of agents**.
This is an experimental project exploring **fractional ownership** using **Intercom**.

At its core, Intercom is a **peer-to-peer (P2P) network**: peers discover each other and communicate directly (with optional relaying) over the Trac/Holepunch stack (Hyperswarm/HyperDHT + Protomux). There is no central server required for sidechannel messaging.
Trading cards are the initial focus because they already sit at the intersection of **physical assets** and **digital ownership**. Their ongoing digitalization and active trading culture make them a natural starting point for testing decentralized, fractional ownership models.

Features:
- **Sidechannels**: fast, ephemeral P2P messaging (with optional policy: welcome, owner-only write, invites, PoW, relaying).
- **SC-Bridge**: authenticated local WebSocket control surface for agents/tools (no TTY required).
- **Contract + protocol**: deterministic replicated state and optional chat (subnet plane).
- **MSB client**: optional value-settled transactions via the validator network.
This repo is a fork-based exploration built on Intercom’s peer-to-peer stack: direct communication, deterministic shared state (contracts), and optional value settlement — without relying on a central platform.

Additional references: https://www.moltbook.com/post/9ddd5a47-4e8d-4f01-9908-774669a11c21 and moltbook m/intercom
## What this aims to build (MVP)

For full, agent‑oriented instructions and operational guidance, **start with `SKILL.md`**.
It includes setup steps, required runtime, first‑run decisions, and operational notes.
**Each trading card becomes its own peer-to-peer asset network:**
- A dedicated **P2P channel** for real-time coordination between holders
- A replicated **ownership state** (shares / cap table) maintained by a contract
- A simple **offer/accept** flow for peer-to-peer share transfers
- Optional settlement later (crypto payments), once the core ownership model is proven

## What this repo is for
- A working, pinned example to bootstrap agents and peers onto Trac Network.
- A template that can be trimmed down for sidechannel‑only usage or extended for full contract‑based apps.
## Why Intercom

## How to use
Use the **Pear runtime only** (never native node).
Follow the steps in `SKILL.md` to install dependencies, run the admin peer, and join peers correctly.
Intercom provides:
- **Sidechannels**: fast P2P messaging for coordination
- **Subnet contracts**: deterministic replicated state for ownership
- **SC-Bridge**: a local authenticated WebSocket interface for apps/agents (no TTY required)
- Optional **settlement** for value transfer

## Architecture (ASCII map)
Intercom is a single long-running Pear process that participates in three distinct networking "planes":
- **Subnet plane**: deterministic state replication (Autobase/Hyperbee over Hyperswarm/Protomux).
- **Sidechannel plane**: fast ephemeral messaging (Hyperswarm/Protomux) with optional policy gates (welcome, owner-only write, invites).
- **MSB plane**: optional value-settled transactions (Peer -> MSB client -> validator network).
## Status

```text
Pear runtime (mandatory)
pear run . --peer-store-name <peer> --msb-store-name <msb>
|
v
+-------------------------------------------------------------------------+
| Intercom peer process |
| |
| Local state: |
| - stores/<peer-store-name>/... (peer identity, subnet state, etc) |
| - stores/<msb-store-name>/... (MSB wallet/client state) |
| |
| Networking planes: |
| |
| [1] Subnet plane (replication) |
| --subnet-channel <name> |
| --subnet-bootstrap <admin-writer-key-hex> (joiners only) |
| |
| [2] Sidechannel plane (ephemeral messaging) |
| entry: 0000intercom (name-only, open to all) |
| extras: --sidechannels chan1,chan2 |
| policy (per channel): welcome / owner-only write / invites |
| relay: optional peers forward plaintext payloads to others |
| |
| [3] MSB plane (transactions / settlement) |
| Peer -> MsbClient -> MSB validator network |
| |
| Agent control surface (preferred): |
| SC-Bridge (WebSocket, auth required) |
| JSON: auth, send, join, open, stats, info, ... |
+------------------------------+------------------------------+-----------+
| |
| SC-Bridge (ws://host:port) | P2P (Hyperswarm)
v v
+-----------------+ +-----------------------+
| Agent / tooling | | Other peers (P2P) |
| (no TTY needed) |<---------->| subnet + sidechannels |
+-----------------+ +-----------------------+
Experimental — research & prototype phase.

Optional for local testing:
- --dht-bootstrap "<host:port,host:port>" overrides the peer's HyperDHT bootstraps
(all peers that should discover each other must use the same list).
```
## Based on

---
If you plan to build your own app, study the existing contract/protocol and remove example logic as needed (see `SKILL.md`).
Intercom by Trac Systems: https://github.com/Trac-Systems/intercom
90 changes: 90 additions & 0 deletions TradingCards
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Fractional Ownership for Trading Cards using Intercom

What if you could own a fraction of a rare trading card—for as little as $10?

This project explores how real-world collectibles like Pokémon, sports cards, or other high-value trading cards can become shared, peer-to-peer owned assets. Instead of relying on centralized platforms, ownership, communication, and trading happen directly between participants using Intercom’s decentralized infrastructure.

Each card becomes its own digital coordination space where holders can:

* own fractions of the asset
* trade shares directly with others
* coordinate decisions (e.g. sell, hold, auction)
* communicate peer-to-peer without intermediaries

This lowers the barrier to entry for collectors and investors, and enables new forms of shared ownership around real-world assets.

---

# Why Intercom

Intercom provides a peer-to-peer networking stack designed for an “internet of agents,” enabling secure communication, shared state, and optional value transfer without centralized servers.

By combining Intercom with fractional ownership logic, each trading card becomes:

* a **peer-to-peer asset channel**
* a **replicated ownership state** managed by contracts
* a **coordination layer** for holders
* a **marketplace without a platform**

This means the asset itself becomes the platform.

---

# Concept Overview

Each trading card is represented as:

**1. Asset Channel (Sidechannel)**
A dedicated Intercom sidechannel for real-time communication and coordination between holders.

**2. Ownership Contract (Subnet plane)**
A deterministic replicated state storing:

* total shares
* ownership distribution
* transfer history

**3. Peer-to-Peer Trading**
Participants can transfer ownership directly, without centralized custody.

**4. Optional Settlement Layer**
Value transfer can be integrated using crypto settlement if required.

---

# Goals of this Repository

This fork serves as an experimental foundation to explore:

* Fractional ownership of real-world collectibles
* Peer-to-peer asset coordination
* Decentralized asset communities
* Agent-native ownership and trading models

---

# Vision

Fractional ownership will transform how real-world assets are owned and traded.

Trading cards are the ideal starting point:

* highly liquid
* globally recognized
* culturally significant
* crypto-native audience

This project is a step toward a future where any real-world asset can exist as a peer-to-peer owned, digitally coordinated entity.

---

# Status

Experimental. Early exploration and prototype phase.

---

# Based on

Intercom by Trac Systems
https://github.com/Trac-Systems/intercom
106 changes: 106 additions & 0 deletions contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Fractional Trading Card Ownership Contract (MVP)
*
* Deterministic replicated state:
* - assets[assetId] = { assetId, totalShares, createdAt }
* - holders[assetId][address] = shares
*
* Commands:
* - create_asset
* - transfer_shares
* - read_asset
* - read_holders
*
* Notes:
* - Minimal prototype. No settlement.
* - Compatible with Protocol.mapTxCommand() which provides { type, value }.
*/

export default function contract (state = {}, message = {}) {
state.assets ??= {};
state.holders ??= {};

const { type, from } = message;

// IMPORTANT: tx protocol may deliver payload as message.value
const args = message.args ?? message.value ?? {};

const asInt = (v) => {
const n = Number(v);
if (!Number.isFinite(n) || !Number.isInteger(n)) throw new Error("INVALID_INT");
return n;
};

const ensureAsset = (assetId) => {
const a = state.assets[assetId];
if (!a) throw new Error("ASSET_NOT_FOUND");
state.holders[assetId] ??= {};
return a;
};

if (type === "create_asset") {
const assetId = String(args.assetId || "").trim();
if (!assetId) throw new Error("ASSET_ID_REQUIRED");

const totalShares = asInt(args.totalShares);
if (totalShares <= 0) throw new Error("TOTAL_SHARES_INVALID");

const initialOwner = String(args.initialOwner || from || "").trim();
if (!initialOwner) throw new Error("INITIAL_OWNER_REQUIRED");

if (state.assets[assetId]) throw new Error("ASSET_ALREADY_EXISTS");

state.assets[assetId] = {
assetId,
totalShares,
createdAt: Date.now()
};

state.holders[assetId] = {
[initialOwner]: totalShares
};

return state;
}

if (type === "transfer_shares") {
const assetId = String(args.assetId || "").trim();
const to = String(args.to || "").trim();
const shares = asInt(args.shares);

if (!assetId) throw new Error("ASSET_ID_REQUIRED");
if (!to) throw new Error("TO_REQUIRED");
if (shares <= 0) throw new Error("SHARES_INVALID");

ensureAsset(assetId);

const fromAddr = String(from || "").trim();
if (!fromAddr) throw new Error("FROM_REQUIRED");

const holders = (state.holders[assetId] ??= {});
const fromBal = asInt(holders[fromAddr] || 0);
if (fromBal < shares) throw new Error("INSUFFICIENT_SHARES");

holders[fromAddr] = fromBal - shares;
holders[to] = asInt(holders[to] || 0) + shares;

if (holders[fromAddr] === 0) delete holders[fromAddr];
return state;
}

if (type === "read_asset") {
const assetId = String(args.assetId || "").trim();
if (!assetId) throw new Error("ASSET_ID_REQUIRED");
const asset = state.assets[assetId] || null;
return { asset };
}

if (type === "read_holders") {
const assetId = String(args.assetId || "").trim();
if (!assetId) throw new Error("ASSET_ID_REQUIRED");
const holders = state.holders[assetId] || {};
return { holders };
}

return state;
}
Loading