A TypeScript utility provided by Validators DAO for decoding Solana shred entry data.
This package is designed to decode Solana entries from shreds, making it easier to work with real-time data streams from the Solana blockchain.
TypeScript alone cannot decode Solana shreds effectively. Therefore, Rust is utilized for efficient decoding, converting the data into JSON format suitable for handling in TypeScript environments.
This utility leverages NAPI (Node-API) instead of WebAssembly (WASM) to decode Solana shred entry data, providing significant practical advantages.
Node-API - Node.js: https://nodejs.org/api/n-api.html#node-api
-
Performance: NAPI delivers near-native performance by directly interfacing with Rust code through bindings, minimizing overhead compared to WebAssembly.
-
Seamless Integration: NAPI simplifies the interoperation between Node.js and Rust, enabling straightforward calls and efficient memory management without extensive tooling or additional complexity.
-
Memory Efficiency: Efficient memory handling with NAPI significantly reduces risks associated with memory leaks or unnecessary garbage collection, common pitfalls when using WASM.
-
Enhanced Debugging and Maintainability: Debugging native modules built with NAPI offers clearer stack traces and robust debugging capabilities, overcoming the opaque debugging difficulties often encountered with WASM.
-
Wide Compatibility: Modules built with NAPI are natively compatible across various Node.js versions without requiring extra compilation steps or environment-specific adjustments.
npm install @validators-dao/solana-entry-decoder
Or using pnpm:
pnpm add @validators-dao/solana-entry-decoder
To directly import this package, you'll need to use the Node.js require
function:
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const { decodeSolanaEntries } = require('@validators-dao/solana-entry-decoder')
For TypeScript projects, it's recommended to import directly from Solana Stream SDK, which exports the decoder in a more convenient way:
pnpm add @validators-dao/solana-stream-sdk
import { decodeSolanaEntries } from '@validators-dao/solana-stream-sdk'
You can find comprehensive usage examples here.
To build binaries for multiple platforms (cross-compilation), you must first install Rust targets for each desired OS and architecture. Execute the following commands once on your machine to enable cross-platform builds:
rustup target add x86_64-unknown-linux-gnu # Linux x64
rustup target add aarch64-unknown-linux-gnu # Linux ARM64
rustup target add aarch64-apple-darwin # macOS ARM64 (Apple Silicon)
rustup target add x86_64-apple-darwin # macOS x64 (Intel)
Here's a concise README section in English that clearly states this is for macOS specifically:
On macOS, to cross-compile for Linux targets (x86_64-unknown-linux-gnu
, aarch64-unknown-linux-gnu
), you must install the following toolchains:
brew tap messense/macos-cross-toolchains
brew install x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu zig
For now please use WSL2 and follow the Linux instructions.
pnpm i
pnpm build
// or from the root of the monorepo
pnpm -F @validators-dao/solana-entry-decoder build
This utility is part of the Solana Stream Monorepo.
For support and further questions, please join our Discord server.
Apache-2.0 License. Refer to the license document.
All contributors must adhere to our Contributor Covenant.