โ† all modules
@metanet-games/

chainseed

๐ŸŽฒ
live on npm zero deps npm โ†— source โ†— Apache-2.0

Verifiable deterministic randomness from a Bitcoin (BSV) block hash โ€” the base primitive the rest of the kit builds on.

Install

$ npm i @metanet-games/chainseed

Example

import { seed } from "@metanet-games/chainseed";

// blockHash: a BSV block hash (lowercase hex, as explorers show it)
const s = seed(blockHash);

s.unit("loot:sword");                 // float in [0,1)
s.int("spawn:3", 6);                  // integer 0..5
s.pick("weather", ["rain","fog","sun"]);
s.chance("crit", 0.1);                // true 10% of the time

Plug it into your game

Anywhere your game needs a random number players must be able to trust, seed it from a block hash instead of Math.random. Everyone with that block computes the same value, and nobody โ€” not even you โ€” can grind it. Draw as many independent values as you like from one block by passing different path strings.

Part of chainkit โ€” verifiable building blocks for BSV games. Verify don't trust.

๐Ÿงฉ github.com/metanet-games/chainkit ยท ๐Ÿ•น๏ธ the games ยท metanet.games