The canonical Codama node specification.
Codama is a standard for describing on-chain Solana programs as a graph of typed nodes (accounts, instructions, types, …). This repository contains:
- The spec. A machine-readable description of every node in the Codama node graph, authored in TypeScript under
src/and emitted asv1/spec.json. Future Codama majors will land alongside asv2/spec.json,v3/spec.json, … - The meta-model API. Authoring helpers (
defineNode,attribute, primitives, compounds, …) exposed at@codama/spec/apifor hand-authoring specs and test fixtures. - Internal codegen. Generators under
generators/produce the public artifacts that mirror each spec major (v<n>/spec.json,v<n>/schema.json,v<n>/docs/). They are not exported from the@codama/specpackage; they exist as internal tooling for this repo.
Reference implementations (TypeScript node types, node factories, visitors, validators, renderers, the CLI) live in codama-idl/codama and consume the published @codama/spec package. The Rust reference implementation lives in codama-idl/codama-rs.
pnpm add @codama/spec
# or: npm install @codama/spec@codama/spec exposes three entrypoints:
@codama/spec— the latest stable major's public surface. Re-exports@codama/spec/v1today; will track future majors.@codama/spec/v1— the v1 spec data, accessors (getSpec,getNode,getUnion,getEnumeration), and the version-agnostic types (NodeSpec,UnionSpec, …).@codama/spec/api— the meta-model authoring API (defineNode,attribute, primitives, compounds, …) for hand-authoring specs and test fixtures.
import { getSpec, getNode, SPEC_VERSION } from '@codama/spec/v1';
const spec = getSpec();
console.log(spec.version); // → '1.6.0'
console.log(SPEC_VERSION); // → '1.6.0'
const account = getNode('accountNode');
console.log(account?.attributes.map(a => a.name));
// → ['name', 'size', 'docs', 'data', 'pda', 'discriminators']import { attribute, defineNode, string, u32 } from '@codama/spec/api';
const myNode = defineNode('myNode', {
docs: ['A custom node, hand-authored.'],
attributes: [attribute('name', string()), attribute('size', u32(), { docs: ['Size in bytes.'] })],
});src/ # package source (the @codama/spec public surface)
tests/ # package tests
generators/ # internal codegen orchestrator + per-target generators
index.ts # runs every registered generator sequentially
json-spec/ # emits v<n>/spec.json
json-schema/ # emits v<n>/schema.json (stub)
docs/ # emits v<n>/docs/ (stub)
v1/ # generated artifacts mirroring the @codama/spec/v1 surface
spec.json
schema.json
docs/
.changeset/ # release intent files (managed by @changesets/cli)
@codama/spec is released through changesets:
- Run
pnpm changeseton your branch to record a bump and a user-facing summary. - Commit the generated
.changeset/*.mdalongside your changes. - On merge to
main, theMainworkflow either opens a "Release package" PR (when changesets are pending) or publishes@codama/specto npm (when versions have been bumped).
The repo is currently in release-candidate mode under the rc tag (see .changeset/pre.json). Every pnpm changeset version produces a 1.6.0-rc.N version. To cut the stable release, run pnpm changeset pre exit, then pnpm changeset version and merge the resulting "Release package" PR.
MIT — same as the rest of the Codama ecosystem.