miniledger 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -35
- package/dashboard/app.js +744 -156
- package/dashboard/index.html +33 -84
- package/dashboard/style.css +500 -75
- package/dist/bin/miniledger.cjs +135 -23
- package/dist/bin/miniledger.cjs.map +1 -1
- package/package.json +33 -9
package/README.md
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/miniledger-banner.svg" alt="MiniLedger — Private Blockchain Framework for Node.js" width="720" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h3 align="center">Private Blockchain Framework for Node.js</h3>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Zero-config permissioned ledger with Raft consensus, smart contracts, SQL queries, and a built-in block explorer.<br/>
|
|
9
|
+
The simplest way to add a distributed ledger to any application.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/miniledger"><img src="https://img.shields.io/npm/v/miniledger.svg" alt="npm version" /></a>
|
|
14
|
+
<a href="https://github.com/Chainscore/miniledger/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="license" /></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D22-brightgreen.svg" alt="node version" />
|
|
16
|
+
<img src="https://img.shields.io/badge/consensus-Raft-blue.svg" alt="Raft consensus" />
|
|
17
|
+
<img src="https://img.shields.io/badge/state-SQLite-orange.svg" alt="SQLite state" />
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
4
21
|
|
|
5
22
|
```
|
|
6
23
|
npm install miniledger
|
|
7
24
|
```
|
|
8
25
|
|
|
9
|
-
MiniLedger is a private
|
|
26
|
+
MiniLedger is a **private blockchain framework** and **permissioned distributed ledger** that runs in a single Node.js process. Unlike Hyperledger Fabric or R3 Corda, there's no Docker, no Kubernetes, no certificate authorities, and no JVM — just `npm install` and you have a production-ready **consortium blockchain** with Raft consensus, JavaScript smart contracts, per-record encryption, on-chain governance, and full SQL queryability.
|
|
27
|
+
|
|
28
|
+
Built for **enterprise use cases** like supply chain tracking, audit trails, multi-party data sharing, tokenized assets, and any scenario where you need an **immutable, tamper-proof ledger** without the overhead of public blockchains or the complexity of legacy DLT platforms.
|
|
29
|
+
|
|
30
|
+
## Why MiniLedger?
|
|
31
|
+
|
|
32
|
+
- **10-second setup** — `npm install miniledger && npx miniledger start`. No infrastructure.
|
|
33
|
+
- **SQL-queryable state** — World state lives in SQLite. Run `SELECT * FROM world_state` directly.
|
|
34
|
+
- **Embeddable** — Import as a library into any Node.js/TypeScript app. No separate processes.
|
|
35
|
+
- **Enterprise-grade consensus** — Raft leader election with log replication and fault tolerance.
|
|
36
|
+
- **Smart contracts in JavaScript** — No Solidity, no Go, no Kotlin. Just plain JS.
|
|
37
|
+
- **Built-in block explorer** — Full dashboard with search, drill-down, and SQL console.
|
|
38
|
+
- **Lightweight alternative** to Hyperledger Fabric, R3 Corda, and Quorum for teams that want a private blockchain without the operational burden.
|
|
10
39
|
|
|
11
40
|
## Quick Start
|
|
12
41
|
|
|
@@ -25,7 +54,7 @@ curl -X POST http://localhost:4441/state/query \
|
|
|
25
54
|
-H "Content-Type: application/json" \
|
|
26
55
|
-d '{"sql": "SELECT * FROM world_state"}'
|
|
27
56
|
|
|
28
|
-
# Open the dashboard
|
|
57
|
+
# Open the block explorer dashboard
|
|
29
58
|
open http://localhost:4441/dashboard
|
|
30
59
|
```
|
|
31
60
|
|
|
@@ -35,9 +64,65 @@ open http://localhost:4441/dashboard
|
|
|
35
64
|
npx miniledger demo
|
|
36
65
|
```
|
|
37
66
|
|
|
38
|
-
Spins up a 3-node Raft cluster
|
|
67
|
+
Spins up a **3-node Raft cluster**, deploys a token smart contract, submits sample transactions, and opens the web dashboard — a full blockchain explorer with block/tx drill-down, state browser, contract viewer, governance page, and search.
|
|
68
|
+
|
|
69
|
+
### Block Explorer Dashboard
|
|
70
|
+
|
|
71
|
+
<p align="center">
|
|
72
|
+
<img src="assets/dashboard-screenshot.png" alt="MiniLedger Block Explorer Dashboard" width="800" />
|
|
73
|
+
</p>
|
|
74
|
+
|
|
75
|
+
The built-in explorer at `http://localhost:4441/dashboard` includes:
|
|
76
|
+
- **Overview** — live stats, block rate chart, recent blocks & transactions
|
|
77
|
+
- **Block explorer** — paginated list, drill into any block to see its transactions
|
|
78
|
+
- **Transaction viewer** — filter by type, click through to full payload details
|
|
79
|
+
- **State browser** — browse all key-value entries or run raw SQL queries
|
|
80
|
+
- **Contract inspector** — view deployed smart contracts and their source code
|
|
81
|
+
- **Governance** — proposals, vote breakdowns, status tracking
|
|
82
|
+
- **Network** — peer list, consensus role, leader info
|
|
83
|
+
- **Search** — find blocks by height, transactions by hash, state keys, or addresses
|
|
84
|
+
|
|
85
|
+
## Transaction Examples
|
|
39
86
|
|
|
40
|
-
|
|
87
|
+
Submit data via `curl` or the CLI:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Store a user record
|
|
91
|
+
curl -X POST http://localhost:4441/tx \
|
|
92
|
+
-H "Content-Type: application/json" \
|
|
93
|
+
-d '{"key": "user:alice", "value": {"name": "Alice", "balance": 500, "role": "admin"}}'
|
|
94
|
+
|
|
95
|
+
# Store a product (supply chain, inventory, etc.)
|
|
96
|
+
curl -X POST http://localhost:4441/tx \
|
|
97
|
+
-H "Content-Type: application/json" \
|
|
98
|
+
-d '{"key": "product:widget-a", "value": {"name": "Widget A", "price": 29.99, "stock": 142}}'
|
|
99
|
+
|
|
100
|
+
# Invoke a smart contract method
|
|
101
|
+
curl -X POST http://localhost:4441/tx \
|
|
102
|
+
-H "Content-Type: application/json" \
|
|
103
|
+
-d '{"type": "contract:invoke", "payload": {"kind": "contract:invoke", "contract": "token", "method": "mint", "args": [5000]}}'
|
|
104
|
+
|
|
105
|
+
# Delete a key
|
|
106
|
+
curl -X POST http://localhost:4441/tx \
|
|
107
|
+
-H "Content-Type: application/json" \
|
|
108
|
+
-d '{"key": "product:widget-a", "value": null}'
|
|
109
|
+
|
|
110
|
+
# Query state with SQL
|
|
111
|
+
curl -X POST http://localhost:4441/state/query \
|
|
112
|
+
-H "Content-Type: application/json" \
|
|
113
|
+
-d '{"sql": "SELECT key, value FROM world_state WHERE key LIKE '\''user:%'\''"}'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Or use the CLI:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
miniledger tx submit '{"key":"sensor:temp-1","value":{"celsius":22.5,"location":"warehouse"}}'
|
|
120
|
+
miniledger query "SELECT * FROM world_state ORDER BY updated_at DESC LIMIT 10"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Programmatic API (Embeddable Blockchain)
|
|
124
|
+
|
|
125
|
+
Use MiniLedger as a library — embed a private blockchain directly in your Node.js application:
|
|
41
126
|
|
|
42
127
|
```typescript
|
|
43
128
|
import { MiniLedger } from 'miniledger';
|
|
@@ -76,16 +161,29 @@ await node.submit({
|
|
|
76
161
|
|
|
77
162
|
| Feature | Description |
|
|
78
163
|
|---------|-------------|
|
|
79
|
-
| **Zero config** | No Docker, no K8s, no certificate authorities. Single process. |
|
|
80
|
-
| **SQL
|
|
81
|
-
| **Raft consensus** |
|
|
82
|
-
| **Smart contracts** | Write contracts in JavaScript.
|
|
83
|
-
| **Per-record privacy** | AES-256-GCM field encryption with ACLs. No channels. |
|
|
84
|
-
| **On-chain governance** | Propose and vote on network changes. Quorum-based. |
|
|
85
|
-
| **
|
|
164
|
+
| **Zero config** | No Docker, no K8s, no certificate authorities. Single Node.js process. |
|
|
165
|
+
| **SQL-queryable state** | World state stored in SQLite. Run SQL queries directly against the ledger. |
|
|
166
|
+
| **Raft consensus** | Production-grade leader election, log replication, and fault tolerance. |
|
|
167
|
+
| **Smart contracts** | Write and deploy contracts in JavaScript. No Solidity required. |
|
|
168
|
+
| **Per-record privacy** | AES-256-GCM field-level encryption with ACLs. No channels needed. |
|
|
169
|
+
| **On-chain governance** | Propose and vote on network changes. Quorum-based decision making. |
|
|
170
|
+
| **Block explorer** | Built-in web dashboard with search, pagination, and drill-down views. |
|
|
86
171
|
| **P2P networking** | WebSocket mesh with auto-reconnect and peer discovery. |
|
|
87
|
-
| **Ed25519 identity** | Audited
|
|
88
|
-
| **TypeScript native** | Full type safety. Dual CJS/ESM package. |
|
|
172
|
+
| **Ed25519 identity** | Audited cryptographic signatures. No PKI setup required. |
|
|
173
|
+
| **TypeScript native** | Full type safety. Dual CJS/ESM package. Embed in any Node.js app. |
|
|
174
|
+
|
|
175
|
+
## Use Cases
|
|
176
|
+
|
|
177
|
+
MiniLedger is ideal for:
|
|
178
|
+
|
|
179
|
+
- **Supply chain tracking** — Immutable record of goods movement across organizations
|
|
180
|
+
- **Audit trails** — Tamper-proof logs for compliance, finance, and healthcare
|
|
181
|
+
- **Multi-party data sharing** — Shared ledger between organizations without a central authority
|
|
182
|
+
- **Asset tokenization** — Issue and transfer digital tokens with smart contracts
|
|
183
|
+
- **IoT data integrity** — Sensor data committed to an immutable ledger
|
|
184
|
+
- **Document notarization** — Timestamped, cryptographically signed record keeping
|
|
185
|
+
- **Internal microservice ledger** — Embed a tamper-proof log in any Node.js backend
|
|
186
|
+
- **Rapid prototyping** — Build and test distributed ledger applications in minutes, not weeks
|
|
89
187
|
|
|
90
188
|
## Architecture
|
|
91
189
|
|
|
@@ -113,22 +211,26 @@ await node.submit({
|
|
|
113
211
|
└────────────┘ └─────────────┘
|
|
114
212
|
```
|
|
115
213
|
|
|
116
|
-
## Multi-Node Cluster
|
|
214
|
+
## Multi-Node Consortium Cluster
|
|
215
|
+
|
|
216
|
+
Set up a multi-organization private network:
|
|
117
217
|
|
|
118
218
|
```bash
|
|
119
219
|
# Node 1 (bootstrap)
|
|
120
220
|
miniledger init -d ./node1
|
|
121
221
|
miniledger start -d ./node1 --consensus raft --p2p-port 4440 --api-port 4441
|
|
122
222
|
|
|
123
|
-
# Node 2
|
|
223
|
+
# Node 2 (joins the network)
|
|
124
224
|
miniledger init -d ./node2
|
|
125
225
|
miniledger join ws://localhost:4440 -d ./node2 --p2p-port 4442 --api-port 4443
|
|
126
226
|
|
|
127
|
-
# Node 3
|
|
227
|
+
# Node 3 (joins the network)
|
|
128
228
|
miniledger init -d ./node3
|
|
129
229
|
miniledger join ws://localhost:4440 -d ./node3 --p2p-port 4444 --api-port 4445
|
|
130
230
|
```
|
|
131
231
|
|
|
232
|
+
Each node maintains a full copy of the ledger. Raft consensus ensures all nodes agree on the same block history, with automatic leader election and fault tolerance.
|
|
233
|
+
|
|
132
234
|
## CLI Commands
|
|
133
235
|
|
|
134
236
|
| Command | Description |
|
|
@@ -148,32 +250,39 @@ miniledger join ws://localhost:4440 -d ./node3 --p2p-port 4444 --api-port 4445
|
|
|
148
250
|
| Endpoint | Method | Description |
|
|
149
251
|
|----------|--------|-------------|
|
|
150
252
|
| `/status` | GET | Node status (height, peers, uptime) |
|
|
151
|
-
| `/blocks` | GET |
|
|
253
|
+
| `/blocks` | GET | Block list (paginated: `?page=N&limit=M`) |
|
|
152
254
|
| `/blocks/:height` | GET | Block by height |
|
|
153
255
|
| `/blocks/latest` | GET | Latest block |
|
|
154
256
|
| `/tx` | POST | Submit transaction |
|
|
155
257
|
| `/tx/:hash` | GET | Transaction by hash |
|
|
258
|
+
| `/tx/recent` | GET | Confirmed transactions (paginated, filterable by `?type=`) |
|
|
259
|
+
| `/tx/sender/:pubkey` | GET | Transactions by sender address |
|
|
260
|
+
| `/state` | GET | State entries (paginated: `?page=N&limit=M`) |
|
|
156
261
|
| `/state/:key` | GET | State entry by key |
|
|
157
262
|
| `/state/query` | POST | SQL query (`{sql: "SELECT ..."}`) |
|
|
263
|
+
| `/search` | GET | Unified search (`?q=<block height, tx hash, key, address>`) |
|
|
158
264
|
| `/peers` | GET | Connected peers |
|
|
159
265
|
| `/consensus` | GET | Consensus state |
|
|
160
266
|
| `/proposals` | GET | Governance proposals |
|
|
267
|
+
| `/proposals/:id` | GET | Proposal by ID |
|
|
161
268
|
| `/contracts` | GET | Deployed contracts |
|
|
162
|
-
| `/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
| **
|
|
170
|
-
| **
|
|
171
|
-
| **
|
|
172
|
-
| **
|
|
173
|
-
| **
|
|
174
|
-
| **
|
|
175
|
-
| **
|
|
176
|
-
| **
|
|
269
|
+
| `/identity` | GET | Node identity |
|
|
270
|
+
| `/dashboard` | GET | Web explorer dashboard |
|
|
271
|
+
|
|
272
|
+
## Comparison with Enterprise Blockchain Platforms
|
|
273
|
+
|
|
274
|
+
| | MiniLedger | Hyperledger Fabric | R3 Corda | Quorum |
|
|
275
|
+
|---|---|---|---|---|
|
|
276
|
+
| **Setup time** | 10 seconds | Hours/days | Hours | Hours |
|
|
277
|
+
| **Dependencies** | `npm install` | Docker, K8s, CAs | JVM, Corda node | JVM, Go-Ethereum |
|
|
278
|
+
| **Config files** | 0 (auto) | Dozens of YAML | Multiple configs | Genesis + static nodes |
|
|
279
|
+
| **Consensus** | Raft (built-in) | Raft (separate orderer) | Notary service | IBFT / Raft |
|
|
280
|
+
| **Smart contracts** | JavaScript | Go/Java/Node | Kotlin/Java | Solidity |
|
|
281
|
+
| **State queries** | SQL | CouchDB queries | JPA/Vault | No native query |
|
|
282
|
+
| **Privacy** | Per-record ACLs | Channels (complex) | Point-to-point | Private transactions |
|
|
283
|
+
| **Governance** | On-chain voting | Off-chain manual | Off-chain | Off-chain |
|
|
284
|
+
| **Dashboard** | Built-in explorer | None (3rd party) | None | None |
|
|
285
|
+
| **Embeddable** | Yes (npm library) | No | No | No |
|
|
177
286
|
|
|
178
287
|
## Tech Stack
|
|
179
288
|
|
|
@@ -184,8 +293,29 @@ miniledger join ws://localhost:4440 -d ./node3 --p2p-port 4444 --api-port 4445
|
|
|
184
293
|
- **HTTP:** Hono
|
|
185
294
|
- **CLI:** Commander
|
|
186
295
|
- **Build:** tsup (dual CJS/ESM)
|
|
187
|
-
- **Tests:** Vitest
|
|
296
|
+
- **Tests:** Vitest (86 tests)
|
|
188
297
|
|
|
189
298
|
## License
|
|
190
299
|
|
|
191
300
|
Apache-2.0
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
<p align="center">
|
|
305
|
+
<br />
|
|
306
|
+
<a href="https://chainscorelabs.com">
|
|
307
|
+
<picture>
|
|
308
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/chainscore-labs-dark.png" />
|
|
309
|
+
<source media="(prefers-color-scheme: light)" srcset="assets/chainscore-labs-light.png" />
|
|
310
|
+
<img src="assets/chainscore-labs-light.png" alt="Chainscore Labs" width="280" />
|
|
311
|
+
</picture>
|
|
312
|
+
</a>
|
|
313
|
+
</p>
|
|
314
|
+
|
|
315
|
+
<p align="center">
|
|
316
|
+
Built by <a href="https://chainscorelabs.com"><strong>Chainscore Labs</strong></a> — blockchain infrastructure and developer tooling.
|
|
317
|
+
<br />
|
|
318
|
+
Need custom blockchain solutions, integrations, or developer tooling?
|
|
319
|
+
<br />
|
|
320
|
+
<a href="mailto:hello@chainscore.finance">hello@chainscore.finance</a> · <a href="https://chainscorelabs.com">chainscorelabs.com</a>
|
|
321
|
+
</p>
|