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/transaction

v0.1.0

Published

Pure-TypeScript Ergo transaction wire codec + validation (browser-clean).

Readme

@ergots/transaction

Pure-TypeScript Ergo transaction wire codec. Parses and serializes ErgoLikeTransaction wire bytes, produces the signing message, and computes transaction ids. Browser-clean. Validated byte-for-byte against fixtures derived from the Ergo reference implementation.

Phase 1 — wire codec

This is a phase 1 release: parse, serialize, derive the signing message, compute the transaction id. Validation (stateless well-formedness, conservation rule, per-input script execution, storage rent, cost) is planned for phases 2–4.

Install

npm install @ergots/transaction

Usage

import { parseTransaction, transactionId, serializeTransaction } from '@ergots/transaction';

const txBytes: Uint8Array = /* bytes from a node or fixture */;

// Parse.
const tx = parseTransaction(txBytes);
console.log('inputs:', tx.inputs.length, 'outputs:', tx.outputCandidates.length);

// Derive the transaction id (32 bytes).
const idBytes = transactionId(tx);
const idHex = Array.from(idBytes).map(b => b.toString(16).padStart(2, '0')).join('');
console.log('txId:', idHex);

// Re-serialize — byte-identical to txBytes.
const reBytes = serializeTransaction(tx);

API

Four functions, one error class.

parseTransaction(bytes: Uint8Array): ErgoLikeTransaction

Parse a complete transaction from wire bytes. Rejects trailing bytes (TxParseError('trailing-bytes')). This is intentionally stricter than sigma-rust's sigma_parse_bytes, matching the JVM modifier-parse path.

serializeTransaction(tx: ErgoLikeTransaction): Uint8Array

Serialize to wire bytes. Enforces io-count bounds on serialize as well as parse.

signingMessage(tx: ErgoLikeTransaction): Uint8Array

Full transaction envelope with each input's proof replaced by an empty proof (VLQ-length-0). This is the pre-image of the transaction id and the Fiat–Shamir message signed by each input's spending proof.

transactionId(tx: ErgoLikeTransaction): Uint8Array

blake2b256(signingMessage(tx)) — exactly 32 bytes. Equals the node-reported transaction id (lowercase base16 of these bytes). Confirmed byte-correct against the fixture corpus.

TxParseError

class TxParseError extends Error {
  readonly code: 'trailing-bytes' | 'token-table-index-out-of-range' | 'count-out-of-range';
}

Thrown by parseTransaction and serializeTransaction. count-out-of-range covers inputs/outputs outside [1, 32767] and data-inputs outside {0}∪[1, 32767]. token-table-index-out-of-range fires when an output candidate references a token id not in the transaction's distinct-token table.

Browser compatibility

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

What is NOT here

  • Signing. Producing SpendingProof.proofBytes requires a sigma prover — out of scope.
  • Transaction construction. Box selection, fee calculation, token change.
  • Node communication. Submit via any conformant Ergo node REST endpoint.
  • Validation. Conservation rule, per-input script verification, cost — planned phases 2–4.

See also

License

MIT