Skip to content

API Reference

The public API is the stable TypeScript surface for creating, updating, and resolving Midnight DIDs. It wraps the Compact contract, wallet/provider setup, ledger-state mapping, and DID Document reconstruction.

Main Flow

Primary APIs

TaskAPI
Build standalone providersStandaloneConfig, buildFreshWallet, configureProviders
Initialize controller stateinitPrivateState, restorePrivateState, requirePrivateState
Create or attach to a DID contractdeploy, createDID, joinContract
Resolve DID stateresolve, getMidnightDIDLedgerState
Rotate controller keyrotateControllerKey
Manage JWK verification methodsaddVerificationMethod, updateVerificationMethod, removeVerificationMethod
Manage SchnorrJubjub methodsaddSchnorrJubjubVerificationMethod, updateSchnorrJubjubVerificationMethod, removeSchnorrJubjubVerificationMethod
Manage verification relationshipsaddVerificationMethodRelation, removeVerificationMethodRelation
Verify native signaturesverifySchnorrJubjubDigestSignature
Manage services and aliasesaddService, updateService, removeService, addAlsoKnownAs, removeAlsoKnownAs
Deactivate a DIDdeactivate

Runnable Example

The issuer bootstrap example is the shortest full TypeScript path for real key material. It creates a DID, publishes Ed25519 authentication and SchnorrJubjub assertionMethod keys, resolves the DID Document, and writes a keystore for a downstream issuer.

Start with API Examples or read the source at packages/api/examples/bootstrap-issuer-did.ts.

Package Split

  • @midnight-ntwrk/midnight-did-api is the high-level runtime facade.
  • @midnight-ntwrk/midnight-did maps ledger state to DID Resolution Results.
  • @midnight-ntwrk/midnight-did-domain validates DID model objects and method ids.
  • @midnight-ntwrk/midnight-did-contract exposes the Compact contract runtime.

Use Libs for package selection details and Quickstart for a complete create/update/resolve flow.

Key Rules

Use addVerificationMethod for Ed25519, X25519, P-256, secp256k1, BLS12381G1, and BLS12381G2 JWKs. Use addSchnorrJubjubVerificationMethod for native Midnight SchnorrJubjub keys. The resolver merges both stores into one DID Document. See Key Model before choosing a key profile.

Generated TypeDoc

Generated TypeDoc pages are available locally when you need symbol-level API detail:

bash
pnpm run docs:api

That command writes docs-site/api/reference/. It is intentionally excluded from the default GitHub Pages build so docs-only changes do not compile Compact contracts or package outputs.

Last updated:

Midnight DID reference implementation