Skip to Content
DocsBasicsBasics

Basics

LODE operates on a simple pipeline: define a schema, compile to binary, fingerprint for integrity, verify on receipt.

Core Concepts

Schema

A .lode file is a JSON document that describes the structure of an encodable object. It defines field names, types, numeric IDs, and whether each field is required.

Vein

Vein is the binary wire format that LODE compiles to. A Vein payload starts with a 4-byte header (magic bytes LD, version, field count) followed by typed field entries.

Fingerprint

A deterministic SHA-256 hash computed from a canonicalized representation of the source object. Because canonicalization sorts keys and arrays, the fingerprint is independent of construction order.

Verification

The verify function decodes a Vein binary back to an object, computes its fingerprint, and checks it against an expected hash. This provides end-to-end integrity from source to wire to destination.

Why Binary Matters on StackNet

Every registration on StackNet — agents, model layers, workflows, compliance policies — costs tokens. The payload you send is measured, and the measurement feeds directly into prompt contracts that debit your balance.

LODE’s Vein format is roughly 60% smaller than the equivalent compact JSON. For a model layer definition, that’s ~90 bytes instead of ~220 bytes. For an agent manifest with skills, compliance, and metadata, the savings compound across every registration, every cache refresh, and every peer-to-peer sync.

FormatModel LayerAgent ManifestCompliance Policy
JSON (compact)~220 bytes~380 bytes~310 bytes
Vein~90 bytes~155 bytes~130 bytes
Savings59%59%58%

When you register an agent fleet of 50 sub-agents, each with a manifest and compliance policy, the difference between JSON and Vein is thousands of tokens saved per sync cycle. Over time, across a distributed registry with hundreds of nodes, Vein encoding directly reduces the token cost of operating the network.

This is not compression — it’s elimination of redundancy. No field names in the payload. No quote characters. No delimiters. Just typed data keyed by numeric IDs, verified by a single SHA-256 fingerprint.

Installation

npm install @stacknet/lode

The package provides both a programmatic API and the lodec CLI.

Programmatic Usage

import { compile, decode, fingerprint, verify, loadLode } from "@stacknet/lode"; // Load a schema const schema = loadLode("model-layer-v1.lode"); // Compile const vein = compile(sourceObject, schema); // Fingerprint const hash = fingerprint(sourceObject); // Decode const decoded = decode(vein, schema); // Verify const ok = verify(vein, hash, schema);
Last updated on