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

midnightwalletsync

v0.3.0

Published

[![npm version](https://img.shields.io/npm/v/midnightwalletsync?style=flat-square)](https://www.npmjs.com/package/midnightwalletsync) [View on npm](https://www.npmjs.com/package/midnightwalletsync)

Readme

MidNight-walletsync

npm version View on npm

A lightweight Midnight wallet synchronization SDK and CLI for keeping one or more wallets synced, saving snapshots locally, and querying balances from a running synced process.

This package is designed for a local workspace. It is not a public RPC replacement and it does not hold any secrets by itself; it reads seeds from your .env file and uses them to build and start wallet instances.

What this SDK does

  • Builds wallets from seed values
  • Starts and keeps wallets synced to the Midnight network
  • Stores wallet snapshots on disk
  • Exposes a tiny local HTTP server for status and balance queries
  • Supports multiple wallets at the same time using aliases like n1, n2, n3
  • Formats balance output in a readable way
  • Shows NIGHT and DUST with decimal formatting

Why this exists

The main idea is to keep a wallet synced once, then reuse that synced wallet state for repeated balance checks and for other local tooling.

That means:

  • you do not need to resync every time
  • another terminal can query the synced wallet
  • other local SDK code can be built on top of the same synced wallet process

Configuration

.env

Seeds are loaded from environment variables.

With the default config, the package expects:

  • wallet_id_n1
  • wallet_id_n2
  • wallet_id_n3

If you change seedBaseName, the variable names change too.

Example:

  • seedBaseName = wallet_id
  • alias = n1
  • expected env key = wallet_id_n1

Commands

Commands are invoked using npx midnightsync <command> in your workspace.

For example:

npx midnightsync sync
npx midnightsync balance n1
npx midnightsync status

Or use the npm script shortcuts:

npm run sync
npm run balance -- n1
npm run status

npx midnightsync init

Creates or refreshes:

  • midnightwalletsync.config.json
  • .env.example
  • .env if missing

Use this first in a fresh workspace.

npx midnightsync sync

Starts the sync runtime.

What happens:

  1. The SDK reads config and seeds
  2. Wallets are built from the seeds
  3. Wallets are started
  4. Sync begins
  5. Snapshots are written into .midnightwalletsync/
  6. A local server starts on http://127.0.0.1:8787

Stop it with Ctrl+C.

npx midnightsync status

Prints:

  • config file location
  • env file location
  • wallet aliases currently configured

npx midnightsync balance <alias>

Reads the latest saved snapshot for a wallet alias and prints balances in a human-friendly format.

Default alias is n1.

Example:

npx midnightsync balance n1
npx midnightsync balance n2

Local HTTP API

When sync is running, the SDK exposes a small local server.

GET /health

Returns whether the server is up.

GET /wallets

Returns the configured wallet aliases.

GET /balance/:alias

Returns the latest snapshot for a wallet alias.

Examples:

  • http://127.0.0.1:8787/balance/n1
  • http://127.0.0.1:8787/balance/n2

Important:

  • the balance endpoint only returns data when the wallet has fully synced
  • if the wallet is not synced yet, it returns a 503
  • if the snapshot does not exist, it returns a 404

Multi-wallet behavior

If walletCount is greater than 1, the SDK starts multiple wallets in parallel.

Each wallet gets an alias:

  • n1
  • n2
  • n3
  • and so on

Each alias maps to a seed key in .env.

This makes it possible to keep several wallets synced in one process.

Typical workflow

  1. Run npx midnightsync init
  2. Put real seeds into .env
  3. Adjust midnightwalletsync.config.json if needed
  4. Run npx midnightsync sync
  5. Open another terminal
  6. Run npx midnightsync balance n1
  7. Query http://127.0.0.1:8787/balance/n1 if you want JSON output

Can other SDKs use this?

Yes, conceptually this SDK can act like a local wallet service.

That means another local SDK can:

  • wait for the wallet to sync
  • read balances and addresses
  • build higher-level logic on top of the synced wallet state

Notes

  • This package is currently scoped to preprod usage
  • Seeds are required for private wallet control
  • Balance queries are intentionally blocked until sync is complete
  • The local server is meant for localhost use only

Troubleshooting

wallet is not fully synced yet

Wait for npm run sync to finish syncing, then query again.

Missing seed for n1

Add the correct seed to .env using the expected key name.

Nothing prints in balance

Check that the wallet alias exists and that the snapshot file is present in .midnightwalletsync/.