npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ergots/scorex

v0.1.0

Published

Pure-TypeScript Scorex wire codec (VLQ, ZigZag VLQ, ByteReader/Writer) plus Ergo block-Header / AutolykosSolution data types shared across @ergots/* packages.

Downloads

79

Readme

@ergots/scorex

Pure-TypeScript Scorex wire-codec layer, block-Header types, and Autolykos v2 PoW verifier. Browser-compatible. Validated byte-for-byte against sigma-rust (ergo-chain-types + sigma-ser, branch integration/ergots).

This package is the shared foundation for @ergots/nipopow and @ergots/ergoscript: it provides the ByteReader / ByteWriter classes, VLQ + ZigZag-VLQ encode/decode, the Header and AutolykosSolution types, digest-length constants, and the Autolykos v2 proof-of-work verifier (verifyAutolykosV2 and decodeCompactBits). Extracting this layer removes duplicate codec implementations across packages and provides a stable, single-source-of-truth for the Ergo block-header wire format.

Install

Currently a workspace package; not yet published to npm.

# Within the ergots monorepo workspace:
npm install @ergots/scorex

Public API

Codec layer

import { ByteReader, ByteWriter, ReaderError, MAX_ARRAY_LENGTH } from '@ergots/scorex';
import { encodeVlqU, decodeVlqU, encodeVlqZigZag, decodeVlqZigZag, readVlqU32 } from '@ergots/scorex';

const r = new ByteReader(bytes);
const n = r.readVlqU();             // plain unsigned VLQ -> number
const s = r.readVlqS();             // ZigZag VLQ -> number (signed)
const big = r.readVlqBigInt();      // plain unsigned VLQ -> bigint (64-bit safe)
const opt = r.readOption(sub => sub.readU8());  // null | T
const arr = r.readArray(sub => sub.readU8());   // T[]

const w = new ByteWriter();
w.writeVlqU(42);
w.writeOption(null, (sub, v) => sub.writeU8(v));
w.writeArray([1, 2, 3], (sub, v) => sub.writeU8(v));
const out = w.toBytes();            // Uint8Array

Block Header types and codecs

import { parseHeader, serializeHeader, serializeHeaderWithoutPow, deriveHeaderId } from '@ergots/scorex';
import type { Header, AutolykosSolution } from '@ergots/scorex';

const header = parseHeader(reader);   // derives id in-process; not read from wire
const bytes  = serializeHeader(header);
const id     = deriveHeaderId(header); // blake2b256(serializeHeader(header)); 32 bytes

Digest helpers

import { BLOCK_ID_LEN, DIGEST32_LEN, AD_DIGEST_LEN, EC_POINT_LEN, readFixed, writeFixed } from '@ergots/scorex';

Autolykos v2 PoW verifier

import { verifyAutolykosV2, decodeCompactBits, AutolykosV1NotSupportedError } from '@ergots/scorex';

const ok: boolean = verifyAutolykosV2(header);  // throws AutolykosV1NotSupportedError on v1 headers
const target: bigint = decodeCompactBits(header.nBits);  // Bitcoin-compact difficulty -> 256-bit target

Verifies an Autolykos v2 proof-of-work solution against the header's self-declared nBits target. v1 headers throw a typed error (sigma-rust parity — neither sigma-rust nor ergo-node-rust verify v1 PoW; v1 is JVM-only territory).

See facts/scorex.md for the full interface contract: all method signatures, type invariants, VLQ semantics, error codes, and source mapping to sigma-rust.

Browser compatibility

Runs unchanged in evergreen browsers and Node >= 20. No Buffer, no node:crypto, no dynamic Node built-ins, no WASM. ESM-only.

All codec functions are pure and synchronous: bytes in, structured result out. No I/O, no clock, no storage.

What this package does NOT do

  • SValue / SType / Expr / ErgoBox types. Package-specific to @ergots/ergoscript.
  • NipopowProof / AvlTreeData / Operation types. Package-specific to their respective packages.
  • base58 / base58check. Single-consumer in @ergots/ergoscript; not promoted to shared layer.

Reference implementation

This package ports the Scorex wire-codec layer and Header types from sigma-rust (sigma-ser/src/vlq_encode.rs, ergo-chain-types/src/header.rs, branch integration/ergots). Every Header and AutolykosSolution test asserts byte-equality against fixtures generated by the sigma-rust reference.

See facts/scorex.md for the load-bearing interface contract and source-mapping table.

License

MIT