Skip to main content

Quickstart: an atom ID and IID offline

Version: V2
View Markdown

Time: 10 minutes · Steps: 6

What you'll build​

Turn the ISRC spelling US-RC1-76-07839 into the canonical IID int:isrc:USRC17607839, a P0 representation, and a deterministic atom ID. The code also proves that equivalent ISRC spellings and different companion context URIs produce the same atom bytes and ID.

This is the packages' golden canonicalization fixture. It is separate from the synthetic recording identities in the music catalog; no recording title or artist is inferred from it.

Before you start​

Use Node 22.18 or newer to run TypeScript directly. Installation needs npm registry access. After installation, the example runs offline with no wallet, RPC, API key, or account. It creates no remote or on-chain record.

Steps​

1. Check Node​

node --version

Confirm the version is at least v22.18.0.

2. Create an ESM project​

mkdir intuition-quickstart
cd intuition-quickstart
npm init -y
npm pkg set type=module

3. Install the pinned builder​

npm install @0xintuition/primitives@0.1.1

Keep the generated lockfile. See installation for other package combinations and declared peers.

4. Save the offline example​

Create quickstart.ts:

import assert from 'node:assert/strict';
import { buildIidAnchor } from '@0xintuition/primitives/anchor';

const result = buildIidAnchor(
'music-recording',
{ isrc: 'US-RC1-76-07839' },
{ contextUris: ['https://example.com/recordings/1'] },
);
if (!result.success) throw new Error(result.errors.join('; '));
const atom = result.value;
assert.equal(atom.iid, 'int:isrc:USRC17607839');
assert.equal(atom.profile, 'p0');
assert.equal(atom.data, atom.iid);

const otherContext = buildIidAnchor(
'music-recording',
{ isrc: 'USRC17607839' },
{ contextUris: ['https://example.org/alternate-evidence'] },
);
if (!otherContext.success) throw new Error(otherContext.errors.join('; '));
assert.equal(otherContext.value.data, atom.data);
assert.equal(otherContext.value.dataHex, atom.dataHex);
assert.equal(otherContext.value.id, atom.id);

console.log(atom.iid);
console.log(atom.profile);
console.log(atom.dataHex);
console.log(atom.id);

success distinguishes a valid result from structured errors. data is the exact canonical IID text for this P0 atom, dataHex encodes those bytes, and id is the bytes32 protocol atom ID. Companion contextUris are discovery information; this code neither fetches nor uploads them.

5. Run the example​

node quickstart.ts

Compare the four lines with Run it below. Keep the IID, profile, exact data, hex bytes, atom ID, and original identity evidence together. Deriving an ID does not prove that an atom exists on a chain or in a Core node.

6. Optionally inspect the IID​

npm install @0xintuition/iid@0.1.1 @0xintuition/iid-registry@0.1.1

Save as inspect.ts, then run node inspect.ts:

import { inspectIntuitionId } from '@0xintuition/iid';
import { classificationForIid } from '@0xintuition/iid-registry';

const iid = 'int:isrc:USRC17607839';
const inspection = inspectIntuitionId(iid);
if (!inspection.valid) throw new Error(inspection.reason);
const classification = classificationForIid(iid);
console.log(inspection.valid);
console.log(classification?.slug ?? 'No classification match');

This fixture prints true and music-recording. Other inputs can be invalid or have no unambiguous classification. Inspection and classification lookup do not execute provider requests.

Run it​

node quickstart.ts

Expected output from the pinned packages:

int:isrc:USRC17607839
p0
0x696e743a697372633a555352433137363037383339
0xd3368a8190d3afd5fb05abd01db8141c09a77c3f290bb7a0ef2ffb2b5acab8d8

The last line is an atom ID, not an IID string. The assertions run before any output; an assertion failure or builder error stops execution.

Next steps​

Sources: Getting started, golden anchor tests.

Applies to V2 · @0xintuition/primitives 0.1.1 · @0xintuition/iid 0.1.1 · @0xintuition/iid-registry 0.1.1