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.
SDK: @did-btcr2/apiCreate, resolve, update, and deactivate DIDs from Node.js or a browser app.
CLI: @did-btcr2/cliThe btcr2 command: DIDs, keys, and config from a terminal.
Packages
Section titled “Packages”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. |
Runtime
Section titled “Runtime”- Node.js 22 or newer. The CLI needs Node.js 24.7 or newer.
- Browsers:
@did-btcr2/api,@did-btcr2/method, and@did-btcr2/aggregationship a prebuilt browser bundle through thebrowserexport 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.
Contributing
Section titled “Contributing”To report bugs or request features, open an issue at github.com/dcdpr/did-btcr2-js/issues.
Local development:
git clone https://github.com/dcdpr/did-btcr2-js.gitcd did-btcr2-jspnpm installpnpm buildpnpm build:testspnpm testThe contributor docs (architecture and ADRs) are in the
docs/ directory of the
monorepo. pnpm docs:build builds them together with the API reference.