Skip to content

nomeforme/bLoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bLoom: A Blockchain Loom for Multiverse Exploration

A //WIP// decentralized implementation of the Loom - an interface for exploring the narrative multiverse generated by probabilistic language models, with blockchain permanence.

What is the Loom?

The Loom treats language models as multiverse generators, allowing to explore the stochastic nature of AI. Rather than forcing linear narratives, weaving the Loom enables:

  • Multiverse Exploration: Navigate branching realities across narrative timelines
  • Selection Pressure: Apply editorial force to guide probability flows
  • Evidential Carving: Construct precise realities through iterative boundary-setting
  • Counterfactual Search: Explore what-if scenarios across parallel branches
  • Collaborative Simulation: Human-AI co-creation of narrative possibility spaces

Why Blockchain?

bLoom extends the Loom's memetic framework with:

  • Permanent Multiverse: Trees and branches persist immutably on-chain
  • Compositional Nodes: Each narrative node exists as an autonomous entity in a smart contract
  • Token Bound Accounts: ERC6551 gives each node its own smart contract wallet
  • Token=Token Economics: Content weight translates to token supply (≈1 token per 3 characters)
  • Multiple Permanence Modes: Full (NFT+Tokens), Lightweight (contract storage), or IPFS (distributed storage)
  • Collaborative Authorship: Narrative branches as composable multiauthor primitives

Architecture

Frontend

  • LiteGraph.js: Interactive visual tree navigation with zoom/pan
  • React: Modern UI with real-time updates via WebSocket
  • Ethers.js: Blockchain wallet integration (MetaMask, etc.)
  • Apollo GraphQL: Real-time blockchain event subscriptions

Backend

  • Express.js: REST API server
  • Socket.IO: Real-time bidirectional communication
  • AI Integration: Multi-model support for text generation
  • IPFS Integration: Content pinning and retrieval

Blockchain

  • Foundry: Smart contract development and testing
  • Anvil: Local Ethereum node for development
  • The Graph: Blockchain event indexing and queries
  • ERC Standards: ERC721 (NFTs), ERC20 (Tokens), ERC6551 (Token Bound Accounts)

Permanence Modes

The Loom's multiverse can be crystallized in three ways:

  1. Full Mode - Compositional Permanence:

    • Each branch becomes an ERC721 NFT entity
    • Content weight manifests as ERC20 token supply
    • ERC6551 Token Bound Account grants each node autonomy
  2. Lightweight Mode - Direct Inscription:

    • Branches carved directly into contract storage
    • Minimal gas overhead for pure narrative persistence
  3. IPFS Mode - Distributed Permanence:

    • Content pinned to the InterPlanetary File System
    • Only cryptographic hash stored on-chain
    • Narrative exists in distributed memory

Smart Contracts

Core Contracts

  • LoomFactory.sol: Factory for deploying tree and NFT contracts
  • LoomTree.sol: Individual tree contract managing nodes and hierarchy
  • LoomNodeNFT.sol: Per-tree ERC721 contract for node NFTs
  • NodeToken.sol: ERC20 token contract for each node (when in Full mode)
  • LoomNFTFactory.sol: Creates individual NFT contracts per tree

ERC6551 Infrastructure

  • ERC6551Registry.sol: Registry for creating Token Bound Accounts
  • ERC6551Account.sol: Smart contract wallet implementation for each NFT

Token Economics

  • Initial Supply: Based on content length (content.length / 3, minimum 1 token)
  • Dynamic Adjustment: Tokens mint/burn when content is edited
  • AI Generation: New nodes get tokens based on AI completion token count
  • Token Bound Accounts: All tokens stored in NFT's own smart contract wallet

Project Structure

contracts/          # Solidity smart contracts & tests
├── LoomFactory.sol
├── LoomTree.sol
├── LoomNodeNFT.sol
├── NodeToken.sol
├── ERC6551Registry.sol
└── test/

frontend/           # React web application
├── src/
│   ├── components/
│   ├── hooks/
│   └── utils/

backend/            # Node.js API server
├── routes/         # REST endpoints
├── services/       # Blockchain & IPFS services
└── socketHandlers/ # WebSocket handlers

bloom-subgraph/     # The Graph indexing
├── schema.graphql
└── src/

scripts/            # Deployment & utilities
config/             # Chain configurations

Quick Start

Prerequisites

  • Node.js v16+
  • Foundry (for smart contracts)
  • MetaMask or compatible wallet

Installation

# Install all dependencies
npm run install-all

# Start local blockchain (in one terminal)
npm run anvil

# Deploy contracts (in another terminal)
npm run deploy

# Start backend server
npm run backend

# Start frontend (in another terminal)
npm run frontend

Visit http://localhost:3000 and connect your wallet.

Chain Management

# View active chain configuration
npm run chain:info

# List all configured chains
npm run chain:list

# Switch active chain
npm run chain:use

# Deploy to specific chain
npm run deploy:to

The Graph Subgraph

Deploy and query blockchain events via GraphQL:

# Deploy subgraph
npm run subgraph:deploy

# Quick deploy (skip codegen)
npm run subgraph:deploy:quick

Query events like TreeCreated, NodeCreated, NodeNFTMinted, TokensMinted, etc.

Development Features

  • Real-time Updates: WebSocket-based synchronization
  • Gas Tracking: Built-in gas usage monitoring (press R)
  • Keyboard Shortcuts: Full keyboard navigation (WASD, hotkeys)
  • Multi-model AI: Switch between AI models on the fly
  • Import/Export: Backup and restore tree structures
  • Mobile Support: Responsive design with touch controls

Usage

  1. Connect Wallet: Click "Connect Wallet" to link MetaMask
  2. Create Tree: Press T or use "Create New Tree"
  3. Navigate: Use WASD keys or click nodes
  4. Generate AI Text:
    • Press Enter to generate child branches
    • Press Shift+Enter to generate siblings
  5. Edit Content: Press G on selected node
  6. Switch Storage: Press L to cycle storage modes
  7. View Modes: Press Q (Path View) or E (Tree View)

Authorship

Claude 4 Sonnet, Claude 4.1 Opus, Claude 4.5 Sonnet, one Human Dev. Inspired by the first Loom.

License

MIT

About

Blockchain Loom for Multiverse Exploration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published