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 🙏

© 2025 – Pkg Stats / Ryan Hefner

block-clock

v1.0.1

Published

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) [![Latest Version](https://img.shields.io/npm/v/block-clock)](https://npmjs.org/package/block-clock) [![npm](https://img.shields.io/npm/dm/block

Downloads

98

Readme

Block Clock

MIT License Latest Version npm

A customizable, zero-dependency clock for your Bitcoin Core node.

blockclock-gif

Table of Contents

Quick Start

CDN

<script
  type="module"
  src="https://unpkg.com/block-clock/dist/index.js"
></script>

For extra security, add sub-resource integrity by calculating the sha384 of the js file: cat block-clock-index.js | openssl dgst -sha384 -binary | openssl base64 -A

Then use it in the script property:

<script
  type="module"
  src="https://unpkg.com/block-clock/dist/index.js"
  integrity="sha384-YOURCOMPUTEDSHA384"
></script>

NPM

npm install block-clock

Basic Usage (Pure HTML)

<block-clock
  rpcUser="<YOUR_RPC_USER>"
  rpcPassword="<YOUR_RPC_PASSWORD>"
  rpcEndpoint="<YOUR_RPC_ENDPOINT>"
  darkMode
>
</block-clock>

How it Works

block-clock is a working web component implementation of the Block Clock designed by the Bitcoin Design Community for the work-in-progress Bitcoin Core App design. The goal of that project is to provide a more intuitive and visually appealing frontend for Bitcoin Core nodes, and block-clock is a part of that effort.

The block-clock works by consuming a set of Bitcoin Core RPC credentials at an endpoint and a set of (optional) props. It can also accept a callback for Bitcoin Core nodes behind a proxy, so long as the response data returned by the proxy matches response returned by Bitcoin Core. Using these, it fetches block data and calculates the time between block confirmations to create a visual display of when each block was mined.

The visualization begins at blocks that were mined within the last 12 hour period. It shows the blocks mined starting from either 12 A.M. or 12 P.M. to the current local time. Therefore, the "fill" of the clock always represents the current local time down to the second. Note: There is also a 1-hour interval mode which can be turned on by setting oneHourIntervals on the block-clock component. This is useful if you want to see the past hour's block times. It is also highly recommended to use when connecting Mutinynet nodes. Mutinynet is a fork of Bitcoin Core which uses 30-second block times to make developing applications easier. Because block times are so short, the clock may not function properly if using the default 12-hour intervals.

By default, unconfirmed blocks are shown in gray and confirmed blocks are shown in shades from red to yellow. The first 6 most recently confirmed blocks having a tint of red, with the most recently confirmed block being completely red, and the next 5 blocks being progressively more yellow, after which the color remains consistent. These colors are fully configurable.

As block data is loaded, it is saved in localStorage in the browser, so that subsequent visits to the page or refreshes won't require data to be reloaded. Only blocks that have been mined since the last block saved to localStorage will need to be loaded.

XState

block-clock uses XState to create state machines that make it easy to model how events change the state of the clock. This has the benefit of making the state changes in the clock easier to reason about, as well as import into other projects.

See the state machine here.

Creating a Bitcoin Core Node with Voltage

Voltage is a quick way to get a Bitcoin Core node up and running, and the block-clock is also integrated on our site. See our docs for more info on creating a Bitcoin Core node.

Usage

block-clock can be used anywhere web components can be used. When working with purely client-side frameworks like React, you may import and use it directly, like so:

React

import "block-clock";

function App() {
  return (
    <div className="App">
      ...
      <div style={{ width: 200, height: 200 }}>
        <block-clock
          rpcUser="<YOUR_RPC_USER>"
          rpcPassword="<YOUR_RPC_PASSWORD>"
          rpcEndpoint="<YOUR_RPC_ENDPOINT>"
          darkMode
        ></block-clock>
      </div>
      ...
    </div>
  );
}

export default App;

In SSR frameworks like Sveltekit or NextJS, be sure to wait for the DOM to load first before importing:

Sveltekit

<script lang="ts">
	import { onMount } from 'svelte';
	onMount(() => {
		import('block-clock');
	});
</script>

<div style="display: flex; justify-content: center; align-items: center; height: 100vh">
	<div style="width: 200px; height: 200px;">
		<block-clock
			rpcUser="<YOUR_RPC_USER>"
			rpcPassword="<YOUR_RPC_PASSWORD>"
			rpcEndpoint="<YOUR_RPC_ENDPOINT>"
			darkMode
		>
		</block-clock>
	</div>
</div>

Connecting to Bitcoin Core RPC locally

By default, Bitcoin Core RPC doesn't handle CORS headers so if you try to connect the blockclock from your browser to a locally running Bitcoin Core instance it will fail. You can solve this putting the RPC endpoint behind a proxy, for example:

npx local-cors-proxy --proxyUrl http://localhost:8332

Where 8332 is the port of the bitcoin core RPC REST server. Then use the proxy url provided in your node's rpcEndpoint.

As an example, here is some code you can use to run a pruned node locally to test the block clock:

~/your/path/to/bitcoin-core/bin/bitcoind \
-rpcuser=admin \
-rpcpassword=admin \
-rpcport=8332 \
-assumevalid=00000000000000000000b863b337fc0fa521dc17b25d1b7b22c78e0609316a6d \
-prune=600

This sets admin as the rpc user and password. If you need instructions on how to install bitcoin core checkout this video (Mac) or look for a tutorial for your specific operating system.

Reference

| Attribute | Type | Description | Default | Example | | ------------------ | --------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | | rpcUser | string | Required. | | <MY-USERNAME> | | rpcPassword | string | Required. | | <MY-PASSWORD> | | darkMode | boolean | Optional. | false | Whether the clock should display in dark mode. | | devMode | boolean | Optional. | false | devMode has some extra logging to simplify the development process. | | oneHourIntervals | boolean | Optional. | Whether the clock should reset every hour. Defaults to false | | (i.e. 12 hours). | | theme | BlockClockTheme | Optional. | The color theme(s) for the blocks. The first color in the array represents the unconfirmed transactions. The index of the item between the first and the last items in the array represent the color of that block's confirmations + 1 (i.e., the color at i = 2 is the color of the block with 1 confirmation, i = 3 is the color of the block with 2 confirmations, etc.). The last color in the array represents the color of all remaining blocks. | See DEFAULT_THEME. |

Storybook

To see the storybook and play around with the various attributes:

yarn storybook

Contributing

If you find a problem, please open an issue. PRs welcome!

Publishing

npm run build
npm run publish

License

MIT