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

@leachain/cte-core

v1.0.4

Published

JavaScript wrapper for the CTE CORE WASM library providing encoding and decoding capabilities.

Readme

LEA Chain CTE-CORE-JS

This library provides a JavaScript interface to the LEA Chain CTE (Common Transaction Encoding) core, which is written in C and compiled to WebAssembly (WASM). It offers a robust and efficient way to encode and decode blockchain transactions in a standardized format.

The library is designed to be used in both Node.js and modern browser environments, providing separate builds for each.

Features

  • High-Performance Encoding/Decoding: Leverages the speed of WASM for all core operations.
  • Independent Instances: Each encoder and decoder instance runs in its own sandboxed WASM environment, preventing conflicts and ensuring data integrity.
  • Fluent Encoder API: A clean, chainable API for building complex transactions step-by-step.
  • Push-Based Decoder: A simple and efficient push-based decoding mechanism that processes an entire buffer at once.
  • Type-Safe: Includes TypeScript definitions for all public APIs.

Installation

npm install @leachain/cte-core

Usage

CteEncoder

The CteEncoder class provides a fluent interface for building CTE-compliant transaction buffers.

import { CteEncoder } from '@leachain/cte-core';

async function buildTransaction() {
    try {
        // 1. Create an encoder instance with a specified buffer capacity.
        const encoder = await CteEncoder.create(4096); // 4KB buffer

        // 2. Add data to the encoder using the fluent API.
        const publicKeyData = new Uint8Array(32).fill(0xAA);
        const signatureData = new Uint8Array(64).fill(0xBB);

        encoder
            .addPublicKeyVector(1, 0, publicKeyData) // 1 key, size code 0
            .addSignatureVector(1, 1, signatureData) // 1 signature, size code 1
            .writeIxDataUint32(12345)
            .writeIxDataBoolean(true);

        // 3. Get the final encoded data.
        const encodedBytes = encoder.getEncodedData();
        console.log('Encoded Data:', encodedBytes);

        // 4. Clean up the encoder instance.
        encoder.destroy();

        return encodedBytes;
    } catch (err) {
        console.error('Failed to encode:', err);
    }
}

CteDecoder

The CteDecoder class processes an encoded buffer and returns the decoded data items.

import { CteDecoder } from '@leachain/cte-core';

async function readTransaction(encodedBytes) {
    try {
        // 1. Create a decoder instance.
        const decoder = await CteDecoder.create();

        // 2. Run the decoder on the encoded buffer.
        const decodedItems = decoder.run(encodedBytes);

        // 3. Process the array of decoded items.
        console.log(`Decoded ${decodedItems.length} items:`);
        for (const item of decodedItems) {
            // The 'type' corresponds to internal CTE type identifiers.
            // The 'data' is a Uint8Array of the raw decoded bytes for that item.
            console.log(`  - Type: ${item.type}, Data:`, item.data);
        }

        // 4. Clean up the decoder instance.
        decoder.destroy();
    } catch (err) {
        console.error('Failed to decode:', err);
    }
}

// Example of running both:
buildTransaction().then(encoded => {
    if (encoded) {
        readTransaction(encoded);
    }
});

API Documentation

This project uses jsdoc to generate API documentation from the source code comments. To generate the documentation locally, run the following command:

npm run build:jsdoc

This will create a docs directory in the project root containing the full HTML documentation.

Building the Project

To build the project from the source, including all Node.js and browser-specific bundles, run:

npm run build

Running Tests

To run the test suite, use the following command:

npm run test