New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

miniledger

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniledger

The SQLite of private blockchains. Zero-config, embeddable, SQL-queryable.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
7
-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

MiniLedger

The SQLite of private blockchains. Zero-config, embeddable, SQL-queryable.

npm install miniledger

MiniLedger is a private/permissioned blockchain that runs in a single Node.js process. No Docker. No Kubernetes. No certificate authorities. Just npm install and go.

Quick Start

# Initialize and start a node
npx miniledger init
npx miniledger start

# Submit a transaction
curl -X POST http://localhost:4441/tx \
  -H "Content-Type: application/json" \
  -d '{"key": "account:alice", "value": {"balance": 1000}}'

# Query state with SQL (!)
curl -X POST http://localhost:4441/state/query \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT * FROM world_state"}'

# Open the dashboard
open http://localhost:4441/dashboard

30-Second Demo

npx miniledger demo

Spins up a 3-node Raft cluster, deploys contracts, submits sample data, and opens a web dashboard.

Programmatic API

import { MiniLedger } from 'miniledger';

const node = await MiniLedger.create({ dataDir: './my-ledger' });
await node.init();
await node.start();

// Submit a transaction
await node.submit({ key: 'account:alice', value: { balance: 1000 } });

// Query state with SQL
const results = await node.query(
  'SELECT * FROM world_state WHERE key LIKE ?',
  ['account:%']
);

// Deploy a smart contract
await node.submit({
  type: 'contract:deploy',
  payload: {
    kind: 'contract:deploy',
    name: 'token',
    version: '1.0',
    code: `return {
      mint(ctx, amount) {
        const bal = ctx.get("balance:" + ctx.sender) || 0;
        ctx.set("balance:" + ctx.sender, bal + amount);
      }
    }`
  }
});

Features

FeatureDescription
Zero configNo Docker, no K8s, no certificate authorities. Single process.
SQL queryableState stored in SQLite. Query with SELECT * FROM world_state.
Raft consensusLeader election, log replication, fault tolerance.
Smart contractsWrite contracts in JavaScript. Deploy via transactions.
Per-record privacyAES-256-GCM field encryption with ACLs. No channels.
On-chain governancePropose and vote on network changes. Quorum-based.
Web dashboardBuilt-in block explorer, state browser, SQL console.
P2P networkingWebSocket mesh with auto-reconnect and peer discovery.
Ed25519 identityAudited crypto. No PKI setup required.
TypeScript nativeFull type safety. Dual CJS/ESM package.

Architecture

                    ┌───────────┐
                    │    CLI    │
                    └─────┬─────┘
                          │
                    ┌─────▼─────┐
                    │   Node    │  (orchestrator)
                    └─────┬─────┘
                          │
      ┌───────┬───────┬───┴───┬───────┬───────┐
      │       │       │       │       │       │
   ┌──▼──┐ ┌─▼───┐ ┌─▼────┐ ┌▼─────┐ ┌▼────┐ ┌▼───────┐
   │ API │ │Raft │ │ P2P  │ │Contr.│ │Gov. │ │Privacy │
   └──┬──┘ └──┬──┘ └──┬───┘ └──┬───┘ └──┬──┘ └───┬────┘
      └───────┴───────┴────┬───┴────────┴────────┘
                    ┌──────▼──────┐
                    │    Core     │  (blocks, transactions, merkle)
                    └──────┬──────┘
              ┌────────────┼────────────┐
        ┌─────▼─────┐           ┌──────▼─────┐
        │  SQLite    │           │  Ed25519    │
        └────────────┘           └─────────────┘

Multi-Node Cluster

# Node 1 (bootstrap)
miniledger init -d ./node1
miniledger start -d ./node1 --consensus raft --p2p-port 4440 --api-port 4441

# Node 2
miniledger init -d ./node2
miniledger join ws://localhost:4440 -d ./node2 --p2p-port 4442 --api-port 4443

# Node 3
miniledger init -d ./node3
miniledger join ws://localhost:4440 -d ./node3 --p2p-port 4444 --api-port 4445

CLI Commands

CommandDescription
miniledger initInitialize a new node (create keys, genesis block)
miniledger startStart the node
miniledger join <addr>Join an existing network
miniledger demoRun a 3-node demo cluster
miniledger statusShow node status
miniledger tx submit <json>Submit a transaction
miniledger query <sql>Query state with SQL
miniledger keys showShow node's public key
miniledger peers listList connected peers

REST API

EndpointMethodDescription
/statusGETNode status (height, peers, uptime)
/blocksGETRecent blocks
/blocks/:heightGETBlock by height
/blocks/latestGETLatest block
/txPOSTSubmit transaction
/tx/:hashGETTransaction by hash
/state/:keyGETState entry by key
/state/queryPOSTSQL query ({sql: "SELECT ..."})
/peersGETConnected peers
/consensusGETConsensus state
/proposalsGETGovernance proposals
/contractsGETDeployed contracts
/dashboardGETWeb dashboard

Comparison

MiniLedgerHyperledger FabricR3 Corda
Setup time10 secondsHours/daysHours
Dependenciesnpm installDocker, K8s, CAsJVM, Corda node
Config files0 (auto)Dozens of YAMLMultiple configs
ConsensusRaft (built-in)Raft (separate orderer)Notary service
Smart contractsJavaScriptGo/Java/NodeKotlin/Java
State queriesSQLCouchDB queriesJPA/Vault
PrivacyPer-record ACLsChannels (complex)Point-to-point
GovernanceOn-chain votingOff-chain manualOff-chain
DashboardBuilt-inNone (3rd party)None

Tech Stack

  • Runtime: Node.js >= 22
  • State: SQLite (better-sqlite3, WAL mode)
  • Crypto: @noble/ed25519 + @noble/hashes (audited, pure JS)
  • P2P: WebSocket mesh (ws)
  • HTTP: Hono
  • CLI: Commander
  • Build: tsup (dual CJS/ESM)
  • Tests: Vitest

License

Apache-2.0

Keywords

blockchain

FAQs

Package last updated on 24 Feb 2026

Related posts