← all modules
@metanet-games/

chainclock

⏱️
live on npm zero deps npm ↗ source ↗ Apache-2.0

A block-driven world tick — one shared clock nobody controls. Derive day/night, seasons and rounds from block height.

Install

$ npm i @metanet-games/chainclock

Example

import { createClock, BLOCKS_PER_DAY } from "@metanet-games/chainclock";

const clock = createClock({ genesis: 900000 }); // height 900000 = tick 0
clock.on("tick", ({ tick, height, hash }) => advanceWorld(tick));

clock.update({ height, hash, time });            // feed new tips
clock.phase(BLOCKS_PER_DAY, ["dawn","day","dusk","night"]);

Plug it into your game

Feed it chain tips and every block becomes a tick — a schedule every player shares with no time server. Derive day/night, seasons, or rounds from block height. Gate meaningful outcomes on tick/hash; the smooth progress() between blocks is for animation only, never for consensus.

Part of chainkit — verifiable building blocks for BSV games. Verify don't trust.

🧩 github.com/metanet-games/chainkit · 🕹️ the games · metanet.games