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

@nexscript/interpreter

v1.2.0-beta.1

Published

Consensus-exact Nexa Script interpreter and step-debugger

Readme

@nexscript/interpreter

Consensus-exact Nexscript interpreter and step-debugger, ported from Nexa's src/script/interpreter.cpp.

Features

  • ScriptMachine — full opcode execution engine supporting stack manipulation, control flow, arithmetic, hashing, signatures, locktime, transaction introspection, and extended BigNum operations
  • DebugSession — step-by-step debugger over unoptimised bytecode with source-span mapping via debugMap
  • Signature checking — TxSignatureChecker (consensus-real, bound to a spending transaction) and DataOnlySignatureChecker (data signatures only, no transaction context)
  • BigNum support — arbitrary-precision integer stack items with configurable modulo (OP_SETBMD)
  • Script flags — a ScriptFlags bitfield mirroring the node's script_flags.h; SCRIPT_UPGRADE2_OPCODES gates bug-for-bug pre/post-hard-fork behaviour (bignum operand order, control-opcode checks)

Installation

npm install @nexscript/interpreter
# or
yarn add @nexscript/interpreter

Usage

Running a script

import { ScriptMachine } from '@nexscript/interpreter'
import { Script } from 'libnexa-ts'

const machine = new ScriptMachine()
machine.beginStep(Script.fromASM('OP_1 OP_2 OP_ADD'))
machine.continue()
machine.endStep()
// machine.stack => [ <Buffer 03> ]

Step debugging

import { DebugSession, DebugSpan } from '@nexscript/interpreter'

const debugMap: DebugSpan[] = [
  { start: 0, end: 1, kind: 'OP_1', location: { start: { line: 1, column: 0 }, end: { line: 1, column: 4 } } },
  { start: 1, end: 2, kind: 'OP_2', location: { start: { line: 1, column: 5 }, end: { line: 1, column: 8 } } },
]

const session = new DebugSession('OP_1 OP_2 OP_ADD', { debugMap })
let frame = session.step()
while (!session.isDone()) {
  console.log(`pos: ${frame.pos}, span: ${frame.span?.kind}, stack: ${frame.stack.length}`)
  frame = session.step()
}
console.log('succeeded:', session.succeeded())

Evaluating an unlocking script

import { evalUnlockingScript } from '@nexscript/interpreter'

const stack = evalUnlockingScript('OP_1 OP_2 OP_3')
// stack => [ <Buffer 01>, <Buffer 02>, <Buffer 03> ]

Signature verification

import { TxSignatureChecker, DataOnlySignatureChecker, verifyDataSignature } from '@nexscript/interpreter'

// Data-only (no transaction context)
const valid = verifyDataSignature(sigBytes, message, pubkeyBytes)

// Transaction-bound (consensus-real OP_CHECKSIG)
const checker = new TxSignatureChecker(tx, inputIndex, subscript)
const machine = new ScriptMachine({ signatureChecker: checker })

API

| Export | Description | |---|---| | ScriptMachine | Full script execution engine | | MachineConfig | Configuration for ScriptMachine | | StackItem | Union type: Uint8Array \| BigNumItem | | DebugSession | Step-debugger with source-span mapping | | DebugSpan | Source span interface (emitted by nexc compiler) | | DebugFrame | Machine state snapshot after each step | | evalUnlockingScript | Run a push-only script and return resulting stack | | spanForPos | Find the innermost debug span covering a position | | ScriptError | Enum of all script error codes | | BigNumItem | Arbitrary-precision integer stack item | | isBigNum | Type guard for BigNumItem | | decodeBigNum / encodeBigNum | BigNum serialization | | decodeScriptNum | CScriptNum decoding with overflow/minimality checks (encode via @nexscript/utils minimallyEncodeInt) | | TxSignatureChecker | Transaction-bound signature verifier | | DataOnlySignatureChecker | Data-signature-only verifier | | verifyDataSignature | Standalone data signature verification | | SignatureChecker | Interface for signature checking | | ImportedState | Transaction context interface | | GroupBalance | Per-group aggregate balance | | TxStateSpecifier | Enum of OP_PUSH_TX_STATE specifiers | | ScriptFlags | Script verify flags bitfield (mirrors the node's script_flags.h) | | DEFAULT_SCRIPT_FLAGS | Default flags used when MachineConfig.flags is omitted | | setFlag / hasFlag | Set/clear and test flag bits |

Dependencies

  • libnexa-ts ^3.0.3
  • @nexscript/utils ^1.1.1

License

MIT