aulneau / stacks-encoding-native-js

Encoding & decoding functions for the Stacks blockchain exposed as a fast native Node.js addon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stacks-encoding-native-js

This project was bootstrapped by create-neon.

NodeJS native addon library written in Rust providing functions for decoding binary/wire formats from the Stacks blockchain. This includes Clarity values, transactions, post-conditions, Stacks and Bitcoin addresses, and more. All of which use ASM/SIMD where available.

Supported platforms

  • Linux (glibc) x86_64
  • Linux (glibc) aarch64
  • Linux (musl) x86_64
  • Linux (musl) aarch64
  • MacOS x86_64
  • MacOS aarch64
  • Windows x86_64

Project Layout

The directory structure of this project is:

/
├── Cargo.toml    # The Cargo manifest file
├── package.json  # The npm manifest file
├── native/       # The Node addon modules built by this project, these are dynamically-linked shared objects
├── src/**/*.rs   # Directory containing the Rust source code for the project
|── index.ts      # Typescript definitions for the js interface exposed by the Node addon
|── loader.js     # Script to determine which addon file to load based on the executing target platform
|── loader.d.ts   # Type defintions for the functions exported by the Node addon
|── builder.js    # Script to build the native Node addon for the executing host platform
├── tests/*.ts    # Js/ts unit tests, primarily testing the Neon (rust<->nodejs) interop layer
└── perf-tests/   # Scripts to run performance benchmarks used by commands in package.json

The Rust source code inside the src/**/deserialize.rs files are responsible for deserializing the Stacks blockchain wire/binary formats defined in SIP-005.

NPM Library Bundling

The Node addon modules for all supported platforms are compiled by CI and bundled inside the npm package. The native binary files are small enough that the bundled npm package is an acceptable ~20 MB in size.

About

Encoding & decoding functions for the Stacks blockchain exposed as a fast native Node.js addon


Languages

Language:Rust 61.4%Language:TypeScript 36.1%Language:JavaScript 2.4%