Chronicle Architecture
Chronicle is the token-gated content ecosystem for the Pokemon LLM Agent. It mints in-game moments as Zora Coins on the Base network and locks exclusive content (save files, high-res art) behind token ownership.
System Overview
The system has migrated from a local Node.js sidecar to a scalable Cloudflare Worker architecture.
Components
-
Pokemon LLM Agent (Python):
- Plays the game.
- Generates content (screenshots, AI art).
- Uploads drafts to the Chronicle Worker via API.
-
Chronicle Worker (Cloudflare):
- API: Hono-based REST API running on Edge Workers.
- Database: D1 (SQLite) stores drop metadata and token mapping.
- Storage: R2 stores images and exclusive files.
- Minting: Uses
viemto interact with Zora Protocol on Base.
-
Chronicle UI (Cloudflare Worker/Static):
- React + Vite frontend.
- Displays the timeline feed.
- Handles wallet connection and "Unlock" signatures.
The Flow
1. Drop Creation (Agent -> Worker)
When a major achievement occurs:
1. Agent: Sends POST /api/drop with images and exclusive files.
2. Worker:
* Uploads files to R2.
* Creates a Draft record in D1.
* (Auto-Post) Mints the Zora Coin on Base.
* Updates D1 with the new contractAddress.
2. Discovery (Frontend -> Worker)
- User: Visits
chronicle.llmletsplay.com. - UI: Fetches
GET /api/feed. - Worker: Returns public metadata (images, description) from D1.
3. Gating & Unlock (User -> Worker)
- User: Clicks "Unlock" on a drop.
- UI: Request signature:
"Authenticate Chronicle Access: [ContractAddr] [Nonce]". - UI: Sends signature to
GET /api/unlock/:id. - Worker:
- Verifies signature matches wallet.
- Calls Base RPC to check
balanceOf(user, contractAddress) > 0. - If valid, generates a signed R2 URL (Time-limited) for the exclusive file.
- Redirects user to the secure download.
4. Human-in-the-Loop (Discord -> Worker)
- Notification: When a draft is created, the Worker sends an Embed to Discord with "Approve", "Edit", and "Delete" buttons.
- Interaction: User clicks a button in Discord.
- Webhook: Discord calls
POST /api/interactionson the Worker. - Verification: Worker verifies the
Ed25519signature using theDISCORD_PUBLIC_KEYto ensure authenticity. - Action:
- Approve: Worker triggers the minting process and updates the Discord message to "Published".
- Edit: Opens the Chronicle Admin UI with
?edit=[id]for immediate editing. - Delete: Marks the draft as deleted in the database.
Content Strategy
Achievement Tiers
| Tier | Platform | Content | Gating |
|---|---|---|---|
| Major | Twitter + Zora | AI Art + Save File | ⭐ High |
| Minor | Zora Only | Screenshot | ⭐ Low |
| Progress | Zora Only | Collage | None |
Exclusive Content Types
- The Save File: The actual
.savfile at the moment of victory. Allows users to "continue" the run. - High-Res Art: 4K upscaled versions of the AI generation.
- Battle Logs: Full JSON logs of competitive battles.
Tech Stack
- Runtime: Cloudflare Workers (V8 Isolation)
- Framework: Hono
- Database: Cloudflare D1
- Storage: Cloudflare R2
- Blockchain: Base (L2), Zora Protocol
- SDKs:
viem,@zoralabs/protocol-sdk
Security
- Zero Trust: The Admin API (
POST /api/drop) is protected by Cloudflare Access. The Python Agent authenticates via a Service Token. - Edge Gating: File access is verified at the edge. No direct R2 public access is allowed for exclusive files.