Atoms
An atom gives an app something to refer to. A catalog might need to refer to a recording, its artist, or its liner notes. For each one, the app chooses data, encodes it as bytes, and derives a 32-byte atom ID. Other apps can refer to those same bytes by ID. The real-world recording, the chosen bytes, and the resulting ID play different roles.
Builds on: Nothing; this is the base of the ladder.
Implemented by: ids, primitives, protocol.
How it works
Suppose a catalog calls a recording “Night Ferry.” Another catalog could use the same title for a different recording, or use a different title for the same recording. Choosing a representation comes first. An app can store the title as text, encode a structured description, or use a canonical identifier for the recording. A short title alone carries no catalog or artist information.
The protocol hashes the exact payload bytes with an atom-specific salt. The ID fits in a Solidity bytes32. Copying the bytes preserves the ID. Adding a trailing space to plain text, or changing the field order in serialized JSON, changes what gets hashed. To recover the payload of an existing atom, read its stored data by ID on the intended deployment. Atom ID derivation · MultiVault atom reads
Example
A historical record contains the ten characters 0xdeadbeef. The same spelling can describe two distinct inputs.
| Meaning | Bytes passed to the hash, in hexadecimal |
|---|---|
| Literal text, encoded as UTF-8 | 0x30786465616462656566 (10 bytes) |
| A hexadecimal byte sequence | 0xdeadbeef (4 bytes) |
calculateAtomId accepts both strings and hex. When the original field meant text, encode it explicitly. This local helper keeps the payload, its byte encoding, and its ID together. The same dataHex can later be reviewed as the creation payload.
import { calculateAtomId as atomIdFromData } from '@0xintuition/ids';
import { stringToHex as encodeData } from 'viem';
export function preserveAtom(data: string) {
const dataHex = encodeData(data);
return { data, dataHex, id: atomIdFromData(dataHex) };
}
Common mistakes
- Hashing the displayed title to look up a structured atom. Use the exact serialized payload or the ID supplied by its publisher.
- Using an ID as the payload for a new atom. Hashing those 32 bytes makes another identifier.
- Assuming a locally calculated ID already exists. Creation on the selected MultiVault checks that the payload is nonempty, fits its configured length limit, and is new. Creation checks
Next
- Triples connect atoms. Deterministic IDs explains how to reproduce their IDs.
- Vaults hold positions in a term.
- Intuition Identifiers name entities. Representation profiles determine which identifying bytes reach the protocol.
- Classifications define shared fields for an entity type. Atom parsing begins with an input whose format may be unknown.
Applies to V2 · @0xintuition/ids 0.1.1 · @0xintuition/primitives 0.1.1 · @0xintuition/protocol 4.1.0