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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nubit/modular-indexer-light-sdk

v0.2.1

Published

WebAssembly-based Nubit Modular Indexer (Light) SDK for Bitcoin meta-protocol verification

Downloads

19

Readme

Modular Indexer (Light) JavaScript SDK Join Nubit Discord Community Follow Nubit On X

👛 User-verifiability shapes into your wallet!

JavaScript SDK for running Modular Indexer (Light) inside your wallets, websites, Chrome extensions, and more!

See our demos for the UniSat wallet extension. More wallet integration on the way!

Installation

[!IMPORTANT] Our JavaScript SDK is only available on the web (browsers), since it introduces web workers for better performance, and they are currently not supported on JavaScript runtimes like Node.js.

Install via npm or other package managers:

npm i @nubit/modular-indexer-light-sdk

Examples

The following example shows how to get the verified balance with a given tick and wallet address.

import {create} from "@nubit/modular-indexer-light-sdk";

// Create the SDK first.
const sdk = await create();

// Run SDK with configurations.
await sdk.run({
    "committeeIndexers": {
        "s3": [
            {
                "region": "us-west-2",
                "bucket": "nubit-modular-indexer-brc-20",
                "name": "nubit-official-00"
            }
        ],
        "da": []
    },
    "verification": {
        "bitcoinRPC": "https://bitcoin-mainnet-archive.allthatnode.com",
        "metaProtocol": "brc-20",
        "minimalCheckpoint": 1
    },
});

// Get the SDK status, e.g. `verifying`.
console.log(await sdk.getStatus());

// Some code here to wait for the SDK status being `verified`...

// If the SDK status becomes `verified`, get the balance.
console.log(await sdk.getBalanceOfWallet("ordi", "123abc456def"));

How it works?

Modular Indexer for the greater good

Check out Modular Indexer (Committee) for the technical details about our user-verifiable execution layer.

WebAssembly for seamless integration

Modular Indexer (Light) is a web service and library in Go, and Go officially supports compiling code into WebAssembly. With this, the possibility of integrating Modular Indexer (Light) everywhere becomes reality.

Web workers for smoother interactivity

Loading and warming up a WebAssembly module inside the main JavaScript thread would be a disaster, where it could freeze the UI and annoy our users.

We start a new web worker to tame the beast of it and communicate with the worker via posting messages.

APIs

create(): Promise<SDK>

Create the SDK instance.

SDK.run(c: Config): Promise<void>

Load the WebAssembly module and get everything started.

SDK.getStatus(): Promise<Status>

Get the SDK status, it could be:

  • "verifying": Still verifying the checkpoints from committee indexers
  • "verified": All checkpoints are verified and consistent to retrieve user data for good
  • "unverified": Checkpoints seem inconsistent and a further reconstruction of checkpoints starts to run

SDK.getBlockHeight(): Promise<number>

Get the current Bitcoin block height.

Throws an error if SDK is still verifying.

SDK.getBalanceOfPkScript(tick: string, pkscript: string): Promise<BalanceOfPkScript>

Get verified balances via PkScript.

Throws an error if SDK is still verifying.

SDK.getBalanceOfWallet(tick: string, wallet: string): Promise<BalanceOfWallet>

Get verified balances via a wallet address.

Throws an error if SDK is still verifying.

SDK.getCurrentCheckpoints(): Promise<Checkpoint[]>

Get current checkpoints from all the committee indexers, for introspection. A checkpoint contains useful information like commitments to track down malicious ones.

Throws an error if SDK is still verifying.

SDK.getLastCheckpoint(): Promise<Checkpoint>

Get the previous checkpoint that is proven to be consistent. This checkpoint could be used internally to reconstruct a new and trusted checkpoint when some malicious committee indexers exist.

Throws an error if SDK is still verifying.

Development

In the toplevel project directory, run this make command to build the WebAssembly module:

make GOOS=js GOARCH=wasm packages/modular-indexer-light-sdk/modular-indexer-light.wasm

And then go back here to start the development server:

cd packages/modular-indexer-light-sdk/
npm run dev

Before publishing a new package, bump the version first, and then do the dry-run:

npm run build
npm pack # to check the list of bundled files
npm publish --access=public