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

blockchain-js-core

v1.0.3

Published

Blockchain demo

Downloads

40

Readme

= Blockchain demo

A simple typescript implementation of a Bitcoin-like distributed blockchain consensus algortihm.

The aim is to have a base work to make experiments with it.

== Introduction

This is perfect for showing simple code on how the bitcoin works, so this can be used as a support for demoes.

This program maintains a distributed database accross active nodes, interconnected by the network.

Since this is written in typescript, blockchain nodes can either run on NodeJS or in the browser.

Traditionnal blockchain implemented concepts :

  • block chain (data is a list of blocks),
  • block validity,
  • proof of work (proof of stake can also be implementation as well as other algorithms,

Concepts not in Bitcoin (as far as I know)

  • branches : like with git, the blockchain structure supports branches. There is a master branch called master, then any branch can be built on it !
  • block data is in Ordered-JSON.

== Build

Do a npm install, followed by tsc.

To run the REST web server : node dist/blockchain-node.js

To run the tests : node dist/index.js

== Documentation

Look first at the index.ts, test.ts and blockchain-node.ts. Those are the executable files.

The main data structure is in block.ts.

Node API is in node-api.ts.

Implementation of a node is in node-impl.ts.

The algorithm for transfering data between nodes is in node-transfer.ts.

Other files are more technical (tools, networking, ...)

=== What does the block store for the users ?

A list of JSON data

=== How are blocks identified

A SHA256 hashing function over the Ordered-JSON representation of the block.

==== Ordered-JSON

The idea is to have only one valid JSON representation of the data.

In JSON one can write one same object in different equivalent forms. For instance :

[source]

{ "a": 5, "b": 6 }

and

[source]

{ "b": 6, "a": 5 }

represent the same data.

This poses a problem because it means that depending on how the data has been JSON serialized, it will get to different SHA256 hashs.

So the solution to this is to have a stricter JSON representation where data has ony one representation. The only difference with normal JSON is that in Ordered-JSON, the fields object data type are serialized by lexical order.

This means that between the two JSON representations above, only the first is a valid Ordered-JSON representation.