# Pinax / Hoststar Research Map integration

## Current state

HoodVista has selected Pinax as the prospective data plane for its Research Map. It now includes a deployable **Hoststar PHP + MySQL service package** at [`hoststar-map-service/`](hoststar-map-service/), but it has not been deployed, configured, or connected to Pinax.

No Pinax account, API key, data egress, database, dataset, or paid service has been created or used by this project. The public app therefore continues to show no holder estimate or relationship graph.

## Design

```text
Pinax archive RPC -> Hoststar scheduled indexer -> Hoststar MySQL -> signed map snapshot -> HoodVista Worker -> browser
```

- The Hoststar indexer reads only ERC-20 `Transfer` logs for a specifically reviewed token from its independently verified deployment block.
- MySQL stores transfer events, balances and aggregate edges. Token values remain canonical decimal strings (`VARCHAR(78)`), so 256-bit token amounts are never rounded.
- `data.hoodvista.com` can expose only the bounded `public/map.php` response. It accepts a short-lived HMAC signature from HoodVista’s Worker and has no browser CORS route.
- The Worker rejects any response that is incomplete, stale, malformed, for a different token, or beyond fixed node/edge/response limits.
- The browser receives the bounded `hoodvista-research-map-v1` snapshot, not raw event history, a Pinax endpoint, a provider key, or the shared signing secret.

This service is intentionally not a generic provider proxy. It performs no wallet connection, transaction, address labelling, entity inference, token launch, or trading action.

## Deployment prerequisites

Before deployment, the owner must explicitly approve the provider plan/cost, one first asset, and the verified deployment block. Obtain the exact HTTPS archive-RPC URL from the authenticated Pinax dashboard; never guess it from documentation.

Hoststar requires PHP 8.1+ with PDO MySQL and cURL, MySQL, a private path outside the public web root, and a cron task at least every ten minutes.

The deployment has three separate private configurations:

| Location | Set there | Never set there |
| --- | --- | --- |
| Hoststar private `config.php` | database credentials, exact `pinax_rpc_url`, `map_shared_secret` | browser-visible code or public web root |
| Hoststar public subdomain | only `public/map.php` | configuration, cron source, or database files |
| HoodVista Sites environment | `HOODVISTA_MAP_SERVICE_URL`, `HOODVISTA_MAP_SERVICE_SECRET` | Pinax endpoint/key or database credentials |

`HOODVISTA_MAP_SERVICE_SECRET` must exactly match Hoststar’s `map_shared_secret`; generate a long random value privately. Both names are deliberately absent from browser JavaScript and from this repository.

## First token activation gate

1. Approve Pinax plan, expected spend, account owner, provider-side caps and alert owner.
2. Create a MySQL database and private configuration on Hoststar; import `schema.sql`.
3. Add **one** reviewed token and its independently verified deployment block to `hv_tokens`; do not infer the block from a pool, name or address.
4. Run the indexer to a fixed safe head. Reconcile sampled balances and transfer counts against independently reproduced RPC reads.
5. Test provider outage, malformed log, duplicate cron, stale map, bad HMAC and reorg recovery behavior.
6. Create the `data.hoodvista.com` subdomain pointing only to the service’s `public/` directory, then set the two HoodVista Sites map variables.
7. Confirm the public page labels coverage, freshness and limitations before exposing a holder count or graph.

The indexer uses a 120-block confirmation delay by default. That lowers ordinary reorg risk but is not a substitute for a documented rebuild/reconciliation procedure. If an indexer detects a wrong historical state, disable the token, review the evidence, and rebuild from the verified deployment block before re-enabling it.

## Response contract

Only a ready, bounded snapshot can reach the browser:

```json
{
  "schema": "hoodvista-research-map-v1",
  "status": "ready",
  "token": "0x...",
  "coverage": { "deploymentBlock": 0, "indexedHeadBlock": 0, "complete": true },
  "holderCount": 0,
  "nodes": [{ "id": "0x...", "balance": "0", "rank": 1 }],
  "edges": [{ "source": "0x...", "target": "0x...", "transfers": 1, "rawVolume": "0" }]
}
```

It represents public on-chain addresses and aggregate covered transfers only. It cannot prove identity, ownership, intent, safety, value, or investment suitability.
