03 · Web3 & UNIMARC: applied researchDocs Running

A Library in One Install

The JavaScript SDK of the World Library: download and read books stored on Arweave, work with the library’s records, and read the library’s smart contracts on Gnosis.

npm install @the_library/public @the_library/network-config
⬡@the_library/public · v3.0.0 on npm ‹›ESM + TypeScript ‹›Vue · React · Solid · Astro adapters
01 · UNIMARC

A library standard, rebuilt for web3.

The Universal MARC format (UNIMARC) is a widely used international standard for the representation and exchange of data in machine-readable form. It covers four metadata schemas for bibliographic, classification, authorities and holdings information.

The primary purpose of UNIMARC is to facilitate the international exchange of data in machine-readable form between national bibliographic agencies. The UNIMARC is maintained by the UNIMARC Committee.

IFLA, UNIMARC

A book, its authors and its subjects are made of the same elements as a UNIMARC record, identified with the same standards (ISBN, Dewey, Library of Congress). The definitions are published once, as @the_library/canonical-schemas, then compiled into @the_library/public, and every record built from them is stored on an immutable blockchain. It becomes a centralised standard for decentralised storage, open to everyone.

Property names in the reader’s language Designed

The schema follows i18n best practice, so @the_library/public can be generated in several languages: a French developer writes livre.titre, a Chinese developer 书.标题, for the same field.

LanguageCodeGenerated property
English eng book.title
French fra book.titre
Chinese zho book.标题
Thai tha book.ชื่อ
Arabic ara not in the schema yet

The names are already in the schema; the published package is English-only for now.

This framework runs the World Library, worldbibliotech.com (opens in a new tab) ↗, which operates within the D-SAFE standard.

Bibliotech
From the Greek βιβλιοθήκη (bibliothḗkē): biblíon, book, and thḗkē, a case or repository. It is the word most languages use for the public institution (bibliothèque, biblioteca, Bibliothek, библиотека), here joined to tech.
Library
From the Latin liber, book, through librarium, a bookcase, and libraria, a bookshop. English is almost alone in using it for the institution: the French librairie, the Italian libreria and the Spanish librería are still bookshops.
02 · Quickstart

Three steps. No knowledge of web3 needed.

  1. 1

    Install

    npm install @the_library/public @the_library/network-config
  2. 2

    Open a book

    Show a cover, then its PDF. Serve file-worker-v2.js and mu-worker-v2.js from dist/downloader/ at your site’s root.

    import { preloadWorkersV2, GetImage, GetPdf, GetObjectUrl, revokeObjectUrl } from '@the_library/public/downloader';
    import { Book } from '@the_library/public/models/models';
    
    preloadWorkersV2();                       // start the workers early
    
    const book = await Book.LoadAsync(bookId);   // bookId: bigint
    img.src = await GetObjectUrl(await GetImage(book.previewTxId));
    
    const edition = book.getDefaultInstance('eng');
    if (edition) frame.src = await GetObjectUrl(await GetPdf(edition.downloadTxId));
    // when the reader closes it: revokeObjectUrl(frame.src)
  3. 3

    Read records

    Read the published registry, then boot the models engine from the collection it points to. Serve patch-worker.js from dist/models/ at the root. Books, people, tags and classification systems then load by ID.

    import { addressLoader } from '@the_library/public/web3';
    import { bootstrapModelsV2 } from '@the_library/public/models/vue';   // or /react, /solid, /astro: see Supported frontends
    import { Book, Tag, Person, NewBookWithId, NewTagWithId, NewPersonWithId } from '@the_library/public/models/models';
    
    await addressLoader.loadManifest('production');
    const corpus = addressLoader.getCollectionCorpus('production');
    
    await bootstrapModelsV2({
      userLang: 'eng',
      models: [
        { type: Book.type, create: NewBookWithId },
        { type: Tag.type, create: NewTagWithId },
        { type: Person.type, create: NewPersonWithId },
      ],
      registry: { dataBlock: corpus, gateway: 'https://arweave.net' },
    });
    
    const title = (await Book.LoadAsync(bookId)).getTitle('eng');
03 · Supported frontends

Five frontends. One engine.

The engine is the same everywhere. Only the boot call and the reactive views change with the framework.

React
/models/react · /downloader/react
bootstrapModelsV2, useLevel, useTrash, useModelUpdate; download and render progress hooks.
Vue
/models/vue · /downloader/vue · /web3/vue
bootstrapModelsV2, useLevel, useTrash, useDraft, useBookSearch; download hooks; the Web3 session (useWeb3Session).
Astro
/models/astro
bootstrapModelsV2 and subscribeRecord. Safe to call on every <ClientRouter /> navigation: it boots once.
Solid.js
/models/solid · /downloader/solid
bootstrapModelsV2, useLevel, useTrash, useDraft, partitions; download hooks.
Vanilla JS
/models/astro · /downloader
No framework: installVanillaReactivity and subscribeRecord, plus the framework-free downloader.
04 · Entry points

One package. Four areas.

/downloader
+ /sw
Download, cache and render book PDFs, covers and pages; optional offline service worker.
/models
+ /models/models
The record engine: cache, reactivity, patches, search, trash, stats. Generated classes Book, Person, Tag, ClassificationSystem, Post.
/web3
+ /network · /registry · /auth
EVM read and write clients, session, subscriptions, registry manifest, signed consent messages.
/branding
+ /branding/assets/*
Shared branding and contact data, logos and favicon.
05 · The research

A public library as the blueprint.

The design of a public library (one shared collection, a personal copy for every reader, public records, open to everyone) is the blueprint for the framework. Each principle below pairs the library idea with the code that carries it.

01Running

A catalogue built from library standards

Identifiers: ISBN, ISSN, ISNI, ORCID. Classifications: Dewey, Library of Congress, UDC, Chinese, BBK, Thai and Colon. A book, its editions, authors and subjects line up with UNIMARC and MARC 21 bibliographic fields; the correspondence table is in @the_library/canonical-schemas.

No UNIMARC record converter is included.

const draft = NewBookWithId(newId);
draft.setTitle('A Study in Scarlet', 'eng');
draft.validateIsbn();
// one validate<Standard>() per standard the model uses
02Running

Sovereign data

The shared catalogue is published on Arweave as compact binary sidecars. Every reader change is a patch saved under the reader’s own account on Gnosis. Book files come from Arweave and are cached in the browser.

await addressLoader.loadManifest('production');
const corpus = addressLoader.getCollectionCorpus('production');
// Factory.save() writes patches under the reader's account
03Running

One shared collection, your own copy

Everyone starts from the same canonical collection. A reader’s edits change their own copy; other readers receive them only by subscribing to that reader.

const subs = getSubscriptionClient(DEFAULT_CHAIN_ID);
const { patches, cursor } = await subs.sync(rootUserId);
const next = await subs.syncSince(cursor);
04Running

Anti-cheat: curation, not likes

Deletions and moves are ordinary patches on the reader’s account, saved publicly on Gnosis. The SDK provides that trail; the ranking itself is computed outside this package. See research 01.

import { trashStore } from '@the_library/public/models';

trashStore.list(Tag.type);    // ids currently deleted or !safe
trashStore.count(Tag.type);
05Running

Identity: an account, not a person

On-chain, an account is an address, a username, a user ID, a country and a language. Accounts are pseudonymous, not anonymous.

import { useWeb3Session } from '@the_library/public/web3/vue';

const { activeAccount } = useWeb3Session();
// address · username · userId · country · language
06Running

Free to use

No paywalls, login walls or ads. Reading, searching and downloading need no account. Saving needs a member account ($2 (join the club, opens in a new tab), or created in bulk by a library); gas is topped up for members.

const client = getReadClient(DEFAULT_CHAIN_ID);
await client.ready;
const members = await client.bouncerStorage.nbAccounts();
07Running

Built to last

Property IDs are permanent, from an append-only dictionary. A storage contract is migrated with every record, never redeployed empty. Book files on Arweave are permanent. No network is hard-coded.

import { DEFAULT_CHAIN_ID } from '@the_library/network-config';
// chains are taken by role: production, staging
08Running

Work offline

An optional service worker answers /ar/<txId> from Cache Storage, so cached books load from plain URLs with or without a network.

import { registerDownloaderSW } from '@the_library/public/downloader/sw';

const status = await registerDownloaderSW({
  allowedOrigins: ['example.org'],
});
if (status.registered) img.src = `/ar/${txId}`;
What isn’t on-chain
  • registry.worldbibliotech.com serves the registry manifest, with the on-chain AddressRegistry as fallback.
  • AWS Lambdas create accounts from an email address, top up gas, and send the recovery and deletion-consent emails.
  • Arweave gateways serve the files.
  • Price oracles are used on chains that have one.
06 · Architecture

Where each piece lives.

Browser app
SDK entry points
Arweave
files · catalogue sidecars
Gnosis
patches · accounts · registry
Off-chain helpers
registry server · AWS · oracles

Schematic; the final figure is to come.

07 · Licence

What the licence allows.

D-Open Code Sovereign Licence 1.1 · LicenseRef-DOCSL-1.1
  • Non-commercial use of unmodified copies (bundling, minifying and caching are fine).
  • Public, anonymous, read-only access: writing to the library’s contracts through the SDK is reserved to the services the licensor authorises.
  • Liquidated damages apply for modifying the code or redirecting its contract addresses (section 16.4).
  • Commercial use or a modified build: contact Pond Enterprise at admin@pondenterprise.com.

In practice, anyone can build a library reader on this package. Building and writing to a library of your own is not available today.

Read the full text →
08 · Built on the SDK

Build a library with one prompt.

Give a coding agent the SDK that runs datapond.earth, @the_library/public, and a short prompt, and it can build a new way into the same collection. This 3D library started from the prompt below.

Build a futuristic 3D library in the browser, using @the_library/public from datapond.earth as the single source of truth. Give it two rooms: the Great Hall of the Library of Congress and the domed Reading Room of State Library Victoria. Show every classification system the library supports on the walls. Give the visitor a bow: an arrow that hits a wall opens a detailed view of that classification system, and choosing a category opens worldbibliotech.com on that topic.

The result: World Class Index, a 3D library where every classification system in the collection hangs on the walls of a starship-style hall modelled on the Library of Congress Great Hall and State Library Victoria’s Reading Room. Explore it in 3D (opens in a new tab)↗
World Class Index · opens in a new tab. The prompt started it; I refined it over later sessions.