A JavaScript/TypeScript client library for the League of Entropy's drand distributed randomness beacon network. Currently at v1.4.2, it provides cryptographic verification of randomness using BLS signatures (BLS12-381). Key differentiators include support for HTTP/WebSocket transports, multi-node fastest-client selection, and optional beacon caching. Ships TypeScript types. Supports modern browsers, Node.js >=10.4, and Deno via CDN. Compared to alternatives like randgen or wolfram, drand-client leverages a decentralized network of independent nodes for publicly verifiable, unbiased randomness.
npm install drand-clientNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
This shows how to create a drand client, fetch the latest beacon, and access its randomness and round number.
Import and use the correct chain hash and public key constants from the library, or provide them explicitly via options.
Update property access: `beacon.randomness` for the random value, `beacon.round` for the round number.
Move `chainVerificationParams` to the options passed to the client (e.g., `HttpChainClient`), not the chain.
Always call `.start()` after constructing `FastestNodeClient`.
Switch to ESM import: `import { fetchBeacon } from 'drand-client'` or use dynamic import: `const { fetchBeacon } = await import('drand-client')`Double-check the chain hash and public key. Use the exported constants `chainHash` and `publicKey` or obtain them from the drand chain's `/info` endpoint.
Use a bundler that transpiles ESM to CommonJS, or use the CDN version which is pre-bundled.