RootIB: RB-20260304210059-65FCF04B

# GravityNet Protocol — JSON Message Schema

> **Version:** 1.0.0  
> **Transport:** WebSocket (`ws://host:4747/ws`)  
> **Encoding:** UTF-8 JSON, one message per WebSocket frame  
> **RootIB:** RB-20260304210059-65FCF04B

---

## Overview

All messages between `gravityNet.html` (browser / control plane) and the
gravity coordinator (backend) are JSON objects with a `type` discriminator.

---

## Browser → Coordinator (outgoing)

### `registerRelay`

Register a new relay node or update an existing one.

```json
{
  "type": "registerRelay",
  "relayId": "orchard-nyc-mbp-01",
  "deviceType": "mac",
  "capacityTier": "standard",
  "payoutAddress": "5XPRrteUXNp5qNjHYuXL8SsehYXmmgvZ5PvWV95Apump",
  "description": "Home office Mac, 24/7 uptime expected",
  "walletAddress": "0xAbCd…"
}
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `relayId` | `string` | ✅ | Human-readable, URL-safe identifier for this relay. |
| `deviceType` | `"mac" \| "iphone" \| "ipad" \| "other"` | ✅ | Apple device category. |
| `capacityTier` | `"light" \| "standard" \| "heavy"` | ✅ | Routing capacity commitment. |
| `payoutAddress` | `string` | ✅ | Wallet address for token rewards. |
| `description` | `string` | — | Free-text notes (location, connectivity, etc.). |
| `walletAddress` | `string \| null` | — | Connected browser wallet; used for identity if provided. |

---

### `toggleRelay`

Start or stop a registered relay node.

```json
{
  "type": "toggleRelay",
  "relayId": "orchard-nyc-mbp-01",
  "desiredState": "start"
}
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `relayId` | `string` | ✅ | Must match a previously registered relay. |
| `desiredState` | `"start" \| "stop"` | ✅ | Requested transition. |

---

### `walletLinked`

Notify the coordinator that the browser wallet has been connected.

```json
{
  "type": "walletLinked",
  "walletAddress": "0xAbCd1234…"
}
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `walletAddress` | `string` | ✅ | EVM address (or Solana public key). |

---

## Coordinator → Browser (incoming)

### `relayStatus`

Periodic update with live relay metrics.

```json
{
  "type": "relayStatus",
  "relayId": "orchard-nyc-mbp-01",
  "online": true,
  "messagesRouted": 4821,
  "uptimeSeconds": 18432,
  "peerCount": 5
}
```

| Field | Type | Description |
|-------|------|-------------|
| `relayId` | `string` | Identifies which relay this update is for. |
| `online` | `boolean` | Whether the relay is currently active. |
| `messagesRouted` | `number` | Cumulative messages routed since start. |
| `uptimeSeconds` | `number` | Cumulative online seconds in current session. |
| `peerCount` | `number` | Number of currently connected mesh peers. |

---

### `earningsUpdate`

Current token earnings summary for the connected session.

```json
{
  "type": "earningsUpdate",
  "totalEarned": 57.8413,
  "symbol": "GRA",
  "dailyYield": 3.1200,
  "routingScore": 87
}
```

| Field | Type | Description |
|-------|------|-------------|
| `totalEarned` | `number` | Total tokens earned (all time). |
| `symbol` | `string` | Token ticker symbol (e.g. `"GRA"`). |
| `dailyYield` | `number` | Projected 24-hour yield at current rate. |
| `routingScore` | `number` | Quality score 0–100 (uptime × throughput × reliability). |

---

### `deepSoilLink`

Assigned DeepSoil node identifier for this relay.

```json
{
  "type": "deepSoilLink",
  "nodeId": "ds-orchard-nyc-mbp-01-4821"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `nodeId` | `string` | Unique identifier in the DeepSoil graph. |

---

### `log`

A log entry to display in the relay or mesh event log.

```json
{
  "type": "log",
  "scope": "relay",
  "level": "info",
  "message": "Relay orchard-nyc-mbp-01 registered (standard / mac)."
}
```

| Field | Type | Values | Description |
|-------|------|--------|-------------|
| `scope` | `string` | `"relay"` \| `"mesh"` | Which log panel to target. |
| `level` | `string` | `"info"` \| `"warn"` \| `"error"` | Severity level. |
| `message` | `string` | — | Human-readable log line. |

---

## Future Extensions

The protocol is designed to be extended with:

| Message Type | Direction | Purpose |
|---|---|---|
| `messageLineage` | Coordinator → Browser | Per-message hash and routing path |
| `signatureVerified` | Coordinator → Browser | iMessage signature validation status |
| `bridgeTelemetry` | Browser → Coordinator | Native Apple bridge health metrics |
| `deepSoilSyncStatus` | Coordinator → Browser | On-chain sync progress for this relay |
| `rewardDistribution` | Coordinator → Browser | Payout tx hash confirmation |

---

## Token Reference

| Field | Value |
|-------|-------|
| Token address | `5XPRrteUXNp5qNjHYuXL8SsehYXmmgvZ5PvWV95Apump` |
| Chain | Solana |
| Pump.fun | <https://join.pump.fun/HSag/f4dnwcgm> |
| Ticker | `GRA` |

---

© 2008–2026 Barbrick Design · RootIB: RB-20260304210059-65FCF04B
