Skip to content

TypeScript

The TypeScript reference implementation lives in the did-btcr2-js monorepo. It is the most complete implementation, and the Demo runs it in your browser.

Start with the SDK or the CLI. They include the lower-level packages.

Package Purpose
@did-btcr2/api The SDK. One facade for the DID operations, the Bitcoin connection, key management, and the CAS. Key pairs, signers, and genesis documents are functions of its sub-facades (api.crypto, api.kms, api.btcr2). It does not re-export the classes of the lower packages.
@did-btcr2/cli The btcr2 command. It wraps the SDK and adds an encrypted keystore and config profiles.
@did-btcr2/method The sans-I/O DID Method: identifiers, beacons, and the Resolver and Updater state machines. Use it to customize the protocol.
@did-btcr2/aggregation Multi-party aggregate beacons (CAS and SMT) with MuSig2, over Nostr or HTTP transports.
@did-btcr2/bitcoin Bitcoin Esplora REST and Bitcoin Core RPC clients with a pluggable HTTP executor.
@did-btcr2/keypair secp256k1 key pairs, Multikey encoding, and the Signer interface (LocalSigner).
@did-btcr2/key-manager Key management: generate, import, sign, and verify, with URN key ids.
@did-btcr2/cryptosuite The bip340-jcs-2025 Data Integrity cryptosuite.
@did-btcr2/common Shared types, errors, JCS canonicalization, and hashing.
@did-btcr2/smt The optimized Sparse Merkle Tree of SMT beacons.
  • Node.js 22 or newer. The CLI needs Node.js 24.7 or newer.
  • Browsers: @did-btcr2/api, @did-btcr2/method, and @did-btcr2/aggregation ship a prebuilt browser bundle through the browser export condition. Public endpoints need a small setup: see Use in a browser.
  • The packages are pure JavaScript (no WASM). Each package ships ESM and CJS.

To report bugs or request features, open an issue at github.com/dcdpr/did-btcr2-js/issues.

Local development:

Terminal window
git clone https://github.com/dcdpr/did-btcr2-js.git
cd did-btcr2-js
pnpm install
pnpm build
pnpm build:tests
pnpm test

The contributor docs (architecture and ADRs) are in the docs/ directory of the monorepo. pnpm docs:build builds them together with the API reference.