Skip to main content

@0xintuition/predicates

Version: V2
View Markdown

What it's for​

The predicate registry provides reusable relationship vocabulary and the atom data that gives each predicate its deterministic ID. It also supplies semantic flags, display helpers, and optional enrichment-document builders.

When to use it​

Use a known predicate subpath for one relationship, or the root registry for discovery. Use classifications for classification-specific object targets; legacy expectedObjectType strings are descriptive hints. Predicate metadata does not create graph edges, infer inverse edges, or upload an IPFS document.

Install​

npm install @0xintuition/predicates@0.1.1 viem@2.31.4

Use ESM import or CommonJS require() on Node 20+. Public subpaths work in both formats. See installation and peer setup and the runtime compatibility limits.

Entry points​

SubpathPurpose
.Registry, deterministic data and IDs, semantic metadata, display and bootstrap helpers.
./*Standalone predicate modules keyed by the exact registry key, such as /byArtist or /sameAs.

Depends on and works with​

Runtime dependencies: @0xintuition/ids.

Published peers: viem ^2.0.0.

Example​

import { calculateAtomId, calculateTripleId } from '@0xintuition/ids';
import {
byArtist,
byArtistAtomData,
byArtistId,
byArtistSpec,
} from '@0xintuition/predicates/byArtist';

// Synthetic local fixture atoms; these strings claim no external identity.
const recordingId = calculateAtomId('example:recording');
const artistId = calculateAtomId('example:artist');
const byArtistTripleId = calculateTripleId(recordingId, byArtistId, artistId);
console.log({
key: byArtistSpec.key,
label: byArtist.name,
data: byArtistAtomData,
predicateId: byArtistId,
tripleId: byArtistTripleId,
});

The key byArtist selects a registry entry; the label by artist is display text. The data is a compact DefinedTerm JSON-LD string containing @context, @type, name, and description in that order. The predicate ID hashes that exact data: changing the description changes the ID even if the label stays the same.

The explicit triple above means recording → by artist → artist. Reversing subject and object changes the assertion and its ID. This computes a triple locally; it does not establish that any term exists on-chain.

See also music catalog.

Source​

Package README at the pinned release.

byArtist specification · Standalone export · Predicate serialization.

Applies to V2 · @0xintuition/predicates 0.1.1