
Brainpedia
Brainpedia turns your Obsidian vault into an AI brain that other agents pay you to query
Demo
About
All useful AI knowledge today sits behind three corporate APIs (OpenAI, Anthropic, Google). You cannot own a domain-specialty model, sell verifiable access to your expertise, or compose multiple specialty AIs together without renting from Big AI. The agent economy is short on supply. Each Brain is a 0G iNFT (ERC-7857) you mint from your Obsidian vault. Notes get compiled into wiki articles by Claude (in-context), uploaded to 0G Storage as a merkle-rooted snapshot, and the iNFT carries the root. You set a per-query price (stored as a human-readable ENS text record like `0.001 OG`), the Brain runs inference on 0G Compute (TEE-attested Qwen 2.5 7B), and returns cited answers. Other agents discover you via ENS subnames (`yourname.bpedia.eth`), authenticate via TTL ENS subname access tokens (`agent7af.client.bpedia.eth`), and route over Gensyn AXL P2P. A Mixture-of-Brains query fans out to N Brains in parallel with an LLM-routed topic shortcut. The synthesis is pay-to-read: the orchestrator returns a plan plus per-brain redacted metadata, the agent settles each brain's sticker price in a single `RoyaltyDistributor.distribute` tx, and only then does the server verify the on-chain `Distributed` events and unlock the cached synthesis. Every layer of the marketplace is on-chain: - Ownership: iNFT - Discovery: ENS - Authorisation: ENS subnames as capability tokens - Payment: OG per query, sticker price per brain - Execution: TEE-verified 0G Compute - Routing: AXL - Enforcement: the synthesis is a server-side cache that only releases on verified settlement No central API to deprecate, no off-chain auth service, no "what happens when the startup dies." The Brain outlives Brainpedia. Live Now @ https://brainpedia.up.railway.app - 2 Brain iNFTs minted - Mixture-mode queries return TEE-attested cited answers fused by a separate TEE-attested orchestrator synthesis call - Royalty splits proven on chain (https://chainscan-galileo.0g.ai/tx/0x9637800e6f7b644ac71cf4900bb272f908628d1bd7f0590a9912a183de56bb0e) -> settled 2 brains in one call 1. Install the published MCP server with a single command, no clone: claude mcp add-json brainpedia '...' --scope user `` 2. Point it at your Obsidian vault either by filesystem path or via the Local REST API plugin (no path needed, auto-discovers from your running Obsidian instance) 3. Say "Set up my Brain" inside Claude Code Permissionless self-mint via `BrainMinter`, no involvement from us required. Each Brain owner pockets every query fee directly to their own wallet.
How it's made
There was no reference implementation for stitching iNFTs, ENS access tokens, P2P routing, and MCP into one coherent system. Each layer's docs assume you are using it standalone. 0G `Brain.sol` (ERC-7857 iNFT) on Galileo for ownership and per-query payment, plus `BrainMinter` (a permissionless wrapper that owns `Brain.sol` and exposes `mintToSender`, so any teammate can self-mint a brain to their own wallet without our involvement) and `RoyaltyDistributor` for one-tx multi-Brain settlement at sticker price (each responding brain receives exactly its advertised `brain.price_query`). 0G Storage covers the KV layer for live edits and the Log layer for merkle-rooted snapshots that bind into the iNFT. 0G Compute is accessed via the official broker SDK with Qwen 2.5 7B. Every per-brain answer is TEE-attested, plus a separate TEE-attested orchestrator-synthesis call fuses the per-brain answers into one coherent response. ENS (Sepolia) Two custom Solidity 0.8.26 registrars (`SubnameRegistrar` and `AccessTokenRegistrar`) using the standard `setSubnodeRecord` plus `setText` flow, with `setApprovalForAll` on both the Registry and the Public Resolver (the Resolver maintains a separate operator allowlist, easy to miss). `brain.price_query` is stored in human-readable form (`0.001 OG`) so users inspecting the record on `sepolia.app.ens.domains` see the price directly, not raw wei. Gensyn AXL Each Brain runs its own axl daemon (Yggdrasil-based) with its own Ed25519 peer id, registered with the Python `mcp_router.py` on port 9003. Cross-Brain calls are `POST /mcp/{peer_id}/brainpedia.brain` over real P2P. The web `/api/query` route also routes through `AxlClient` when `AXL_API_URL` is set. Pay-to-Read Enforcement The mixture API is two-phase: 1. Phase 1: fans out, runs the TEE-attested synthesis, caches the full result under a `sessionId`, returns a redacted plan plus per-brain metadata plus the sticker-priced payment plan 2. Settlement: the agent settles via `RoyaltyDistributor.distribute` in one tx, then re-calls with `sessionId` and `txHash` 3. Phase 2: the server loads the receipt via viem, decodes the `Distributed` events, confirms each `(tokenId, amount)` from the cached plan was paid, and only then releases the synthesis. There is no honor-system path. Anthropic MCP TypeScript SDK 7 client tools shipped to npm as `brainpedia-mcp` so users can install with one command (`claude mcp add-json`) and drop straight into Claude Code: - setup_brain `with per-call `vaultRootPath` so Claude can ask which user folder to compile - `upload_articles` - `finalize_brain` with auto-filled `brain.compute_url` - `sync_vault` - `query_brain` - `query_mixture` for phase 1 - `settle_mixture` for phase 1.5 plus phase 2 The split between `query_mixture` and `settle_mixture` lets the host LLM surface the cost to the user and wait for explicit confirmation between calls. No silent settlements. Obsidian `setup_brain` reads vaults two ways: 1. From a filesystem path (`BRAINPEDIA_DEFAULT_VAULT_PATH`) 2. From the https://github.com/coddingtonbear/obsidian-local-rest-api plugin at `OBSIDIAN_REST_API_URL` (defaults to `http://localhost:27123`) The hosted demo runs Obsidian plus the plugin in a KasmVNC container on Railway, exposing the REST endpoint via a Railway TCP proxy. Per-user folders inside the shared vault are scoped via `OBSIDIAN_VAULT_PATH` (env default) or the per-call `vaultRootPath` argument the LLM passes when the user picks their handle.