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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@btc-vision/plugin-sdk

v1.0.0

Published

SDK for developing OPNet node plugins

Readme

@btc-vision/plugin-sdk

Bitcoin TypeScript NodeJS NPM Gulp ESLint

code style: prettier

TypeScript SDK for developing OPNet node plugins. Provides type definitions, interfaces, and base classes for plugin development.

Installation

npm install @btc-vision/plugin-sdk

Quick Start

import { PluginBase, IPluginContext, IBlockProcessedData, IReorgData } from '@btc-vision/plugin-sdk';

export default class MyPlugin extends PluginBase {
    public async onLoad(context: IPluginContext): Promise<void> {
        await super.onLoad(context);
        this.context.logger.info('Plugin loaded!');
    }

    public async onBlockChange(block: IBlockProcessedData): Promise<void> {
        this.context.logger.info(`New block: ${block.blockNumber}`);

        // Store data in plugin database
        if (this.context.db) {
            await this.context.db.collection('blocks').insertOne({
                height: block.blockNumber.toString(),
                hash: block.blockHash,
                timestamp: Date.now(),
            });
        }
    }

    public async onReorg(reorg: IReorgData): Promise<void> {
        // CRITICAL: Handle chain reorg - delete data for reorged blocks
        if (this.context.db) {
            await this.context.db.collection('blocks').deleteMany({
                height: { $gte: reorg.fromBlock.toString() },
            });
        }
    }
}

Plugin Manifest (plugin.json)

Every plugin requires a plugin.json manifest file:

{
    "name": "my-plugin",
    "version": "1.0.0",
    "opnetVersion": "^1.0.0",
    "main": "dist/index.jsc",
    "target": "bytenode",
    "type": "plugin",
    "checksum": "sha256:...",
    "author": { "name": "Your Name" },
    "pluginType": "standalone",
    "permissions": {
        "database": {
            "enabled": true,
            "collections": ["my-plugin_blocks"]
        },
        "blocks": {
            "onChange": true
        }
    }
}

API Reference

See OIP-0003 for the complete specification.

Core Interfaces

| Interface | Description | |-----------|-------------| | IPlugin | Main plugin interface with all lifecycle hooks | | IPluginContext | Runtime context provided to plugins | | PluginBase | Abstract base class with no-op defaults |

Hook Types

Lifecycle Hooks

  • onLoad(context) - Called when plugin is loaded
  • onUnload() - Called when plugin is unloaded
  • onEnable() - Called when plugin is enabled
  • onDisable() - Called when plugin is disabled

Block Hooks

  • onBlockPreProcess(block) - Before block processing (raw Bitcoin data)
  • onBlockPostProcess(block) - After block processing (OPNet data)
  • onBlockChange(block) - New block confirmed

Epoch Hooks

  • onEpochChange(epoch) - Epoch number changed
  • onEpochFinalized(epoch) - Epoch merkle tree complete

Mempool Hooks

  • onMempoolTransaction(tx) - New transaction in mempool

Critical Hooks (BLOCKING)

  • onReorg(reorg) - Chain reorganization (MUST handle for data consistency)
  • onReindexRequired(check) - Reindex required at startup
  • onPurgeBlocks(from, to) - Purge data for block range

APIs

| API | Description | |-----|-------------| | IPluginDatabaseAPI | MongoDB-like database access | | IPluginFilesystemAPI | Sandboxed file system access | | IPluginLogger | Logging with automatic plugin name prefix | | IPluginConfig | Plugin configuration management |

Permissions

Plugins declare required permissions in their manifest:

interface IPluginPermissions {
    database?: {
        enabled: boolean;
        collections: string[];
    };
    blocks?: {
        preProcess: boolean;
        postProcess: boolean;
        onChange: boolean;
    };
    epochs?: {
        onChange: boolean;
        onFinalized: boolean;
    };
    mempool?: {
        txFeed: boolean;
    };
    api?: {
        addEndpoints: boolean;
        addWebsocket: boolean;
    };
    filesystem?: {
        configDir: boolean;
        tempDir: boolean;
    };
}

License

Apache-2.0

Contributing

See CONTRIBUTING.md for guidelines.