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

@odatano/nightgate

v0.35.0

Published

CAP Plugin: Midnight Blockchain Indexer with OData V4 API

Readme

NIGHTGATE - OData for Midnight @odatano/nightgate

Header Image

SAP CAP plugin: Midnight blockchain indexer + transaction submission, exposed as OData V4.

Tests Coverage npm npm downloads npm nightgate-tx nightgate-tx downloads SAP CAP License

@odatano/nightgate connects SAP CAP to the Midnight blockchain. A crawler indexes blocks from a Substrate RPC node into CAP entities; a wallet stack in a worker thread submits transactions (Compact deploys and calls, NIGHT and custom-token transfers, dust generation, fee sponsoring). Everything is exposed as OData V4.

                            ┌──────────────────────────────────────┐
                            │      Midnight Preview / Preprod      │
                            │   Substrate Node    GraphQL Indexer  │
                            └──────────────┬──────────────┬────────┘
                                           │              │
                            wss://         │ Substrate    │ GraphQL
                            JSON-RPC       │ RPC          │ HTTP + WS
                                           ▼              ▼
┌───────────────────────────────────────────────────────────────────────────┐
│  NIGHTGATE                                                                │
│                                                                           │
│  Main thread                              Worker thread                   │
│  ┌──────────────────────┐                 ┌──────────────────────────┐    │
│  │  Crawler             │                 │  Wallet SDK              │    │
│  │  - BlockProcessor    │                 │                          │    │
│  │  - reorg detection   │                 │  - facade.start (sync)   │    │
│  └─────────┬────────────┘                 │  - transferTransaction   │    │
│            │ atomic writes                │  - finalize (ZK prove)   │    │
│            ▼                              │  - registerForDustGen    │    │
│  ┌──────────────────────┐                 │  - deployContract        │    │
│  │  CAP DB              │◄────state-save──┤  - submitContractCall    │    │
│  │  (SQLite / HANA)     │   periodic save │                          │    │
│  └─────────┬────────────┘                 │ - private-state-rpc      │    │
│            │ OData V4                     └──────────┬───────────────┘    │
│            ▼                                         │                    │
│  5 services on /odata/v4/midnight{,-indexer,-analytics,-admin,-verify}    │
└───────────────────────────────────────────────────────────────────────────┘

The wallet SDK runs in a worker thread because its sync saturates the microtask queue; the CAP request pipeline stays responsive.

Quick start

npm ci
npm run dev           

Or standalone with Docker (docs/docker.md):

docker pull ghcr.io/odatano/nightgate:latest
docker run -d -p 4004:4004 \
  -e ENCRYPTION_KEY=$(openssl rand -hex 32) \
  -e NIGHTGATE_HTTP_PASSWORD=change-me \
  -v nightgate-data:/data \
  ghcr.io/odatano/nightgate:latest

.env (see .env.example):

NIGHTGATE_NETWORK=preprod
NIGHTGATE_NODE_URL=wss://rpc.preprod.midnight.network/
# GraphQL indexer, HTTP; the WS URL is derived
NIGHTGATE_INDEXER_HTTP_URL=https://indexer.preprod.midnight.network/api/v4/graphql
# Unset = in-process wasm proving. Setting it selects server proving (production).
# NIGHTGATE_PROOF_SERVER_URL=http://localhost:6300
NIGHTGATE_CRAWLER_ENABLED=false
ENCRYPTION_KEY=<random secret>

First sync walkthrough: docs/quickstart.md.

Services & capabilities

| Service | Path | Content | |---|---|---| | NightgateService | /odata/v4/midnight | chain data, wallet sessions, token / contract / attestation actions | | NightgateIndexerService | /odata/v4/midnight-indexer | sync state, health, metrics, crawler control | | NightgateAnalyticsService | /odata/v4/midnight-analytics | aggregate counts | | NightgateAdminService | /odata/v4/midnight-admin | sessions, contract registration, diagnostics | | NightgateVerifyService | /odata/v4/midnight-verify | unauthenticated state verification (NIGHTGATE_PUBLIC_VERIFY=true) |

Submit actions are async: they return { jobId, status }; poll getJobStatus(jobId, sessionId). Signatures, error codes and examples: docs/actions.md.

| Capability | Surface | |---|---| | Block indexing | Crawler with reorg detection; OData queries on Blocks, Transactions, ContractActions, UnshieldedUtxos, NightBalances | | Wallet sessions | connectWallet (viewing key, read-only), connectWalletForSigning (BIP39 mnemonic, Lace-compatible HD derivation); AES-256-GCM at rest, bound to the requesting user | | Token ops | sendNight (ledger from the receiver address; tokenTypeHex for custom tokens), registerForDustGeneration / deregisterFromDustGeneration | | Fee sponsoring | Dust generation delegation (dustReceiverAddress) and per-tx sponsorSessionId on submit actions (platform sponsors: NIGHTGATE_FEE_SPONSOR_SESSION) | | Pre-flight | getWalletBalance, estimateSendNightFee, deriveWalletInfo | | Compact contracts | deployContract, submitContractCall, submitContractCallBatch on registered artifacts | | Proving | wasm in-process (default without a proof server) or server (selected by a proof-server URL; production). Override: NIGHTGATE_PROVING_MODE | | Document anchoring | anchorDocument / verifyDocument: hash on chain, storage stays with the caller | | Document ingestion | prepareDocumentProof: canonical JSON -> payloadHash + salted content root with per-field inclusion paths (16 slots, 32 on attestation-vault-32); prepareMembershipSet: canonical allow-list root. Compute-only | | Agent access | createAgentGrant / createAgentGrants / updateAgentGrant / rotateAgentGrantToken / revokeAgentGrant: scoped bearer tokens (x-agent-token) with action allow-list, budgets, pinned session and sponsor; attestAgentOutput: verifiable agent-output provenance. MCP server: @odatano/nightgate-mcp | | Agent markets | sponsorSwap settles a shielded swap from two proven halves; the offer board (postSwapOffer / listSwapOffers / getSwapOffer / retireSwapOffer, anonymous getBoardStatus) carries maker halves as offer files; mintFactoryToken mints a session's own named tokens on the token-factory lineage | | Field proofs | issueFieldPredicateAttestation (value <= / >= threshold), issueFieldEqualityAttestation (value behind a public digest), issueFieldMembershipAttestation (one of up to 64 allowed values); issueFieldPredicateAttestationBatch: up to 8 mixed claims in one tx. Values stay hidden | | Cross-document proofs | issueDocumentIntegrityAttestation (B differs from A only in a slot mask), issueDocumentDiffAttestation (at least k slots differ); same width only | | Crawler-free verification | verifyAttestationState, verifyPredicateState, reindexDisclosures: live contract state from the public indexer, optional network override | | Tiered disclosure | grantDisclosure / revokeDisclosure / registerGranteeIdentity, DisclosureGrants index, AttestationService with three tiers | | Local tx building | @odatano/nightgate/txbuilder or @odatano/nightgate-tx: build, prove and sign with your own key, then sponsorFinalizedTransaction / sponsorUnboundTransaction pays and submits. The sponsor sees no key, witness or preimage | | Browser | @odatano/nightgate/browser + GET /zk-config/<contract>/… + GET /contract-manifest: wallet-driven dApps without Compact toolchain or managed/ artifacts | | Operations | Health, liveness, readiness, Prometheus metrics, crawler pause / resume / reindex, offline start |

Documentation

Use as a CAP plugin in another app

cd my-cap-app
npm install @odatano/nightgate @cap-js/sqlite
{
  "cds": {
    "requires": {
      "db": { "kind": "sqlite" },
      "nightgate": { "network": "preprod" }
    }
  }
}

Then cds watch. network is the only required key; the defaults are the public RPC and indexer and wasm proving. Configuration: docs/reference.md#configuration.

Development

npm run dev                # cds watch, 12 GB heap
npm run serve:sync         # cds-serve, 12 GB heap; for long syncs and e2e runs
npm run sync:start         # create a wallet session on the running server

npm run typecheck
npm run lint
npm test                   # Vitest with coverage
npm run build              # CDS types + TypeScript

# Real SDK, no chain access
npm run smoke:sdk
npm run integration:providers   # also: wallet-keys, wallet-facade, contract-registry,
                                #   connector-routes, attestation-vault, derive-wallet-info

# Live e2e on preprod (funded wallet)
npm run deploy:e2e         # more lanes: docs/operations.md

License

Apache-2.0

Links