const result = await wallet.resolveDID('did:bsv:<your-txid>')
console.log(result.didDocument) // DID Document
console.log(result.didDocumentMetadata) // { created, updated, versionId }
Browser: wallet.resolveDID(did)
1. Check local basket (own DIDs) → fast return
2. Call proxy: GET /api/resolve-did?did=did:bsv:<txid>
Proxy (server-side):
1. Try nChain Universal Resolver
- 200 → return document
- 410 → return deactivated
2. On any nChain error → WoC chain-following:
a. Fetch TX from WoC
b. Parse OP_RETURN for BSVDID marker
c. Follow output 0 spend chain
d. Return last document found
// app/api/resolve-did/route.ts
import { createDIDResolverHandler } from '@bsv/simple/server'
const handler = createDIDResolverHandler()
export const GET = handler.GET
// Wallet A creates a DID
const { did } = await walletA.createDID()
console.log(did) // 'did:bsv:d803b04a...'
// Wallet B resolves it (goes through proxy → WoC chain-following)
const result = await walletB.resolveDID(did)
console.log(result.didDocument) // Full DID Document
console.log(result.didDocumentMetadata) // { created, updated, versionId }
const { txid } = await wallet.deactivateDID('did:bsv:<txid>')
console.log('Deactivated in TX:', txid)
// Resolving a deactivated DID returns:
// { didDocumentMetadata: { deactivated: true } }
const dids = await wallet.listDIDs()
for (const entry of dids) {
console.log(entry.did, entry.status) // 'active' or 'deactivated'
}
import { DID } from '@bsv/simple/browser'
// Build a DID Document from a known txid and public key
const doc = DID.buildDocument(txid, subjectPubKeyHex)
// Create a DID string from a txid
const did = DID.fromTxid('d803b04a...')
// Parse and validate
DID.parse('did:bsv:d803b04a...') // { method: 'bsv', identifier: 'd803b04a...' }
DID.isValid('did:bsv:d803b04a...') // true
// Legacy: derive DID from identity key (deprecated)
const doc = wallet.getDID()
await wallet.registerDID()
// Legacy DIDs resolve automatically (no chain following needed)
const result = await wallet.resolveDID('did:bsv:02a1b2c3...')
import { ServerWallet } from '@bsv/simple/server'
const wallet = await ServerWallet.create({ privateKey: '...' })
// No didProxyUrl needed — server-side has no CORS restrictions
const result = await wallet.resolveDID('did:bsv:<txid>')