High-level wallet APIs for browser and server, with deterministic identity-key DIDs and signature-preserving encrypted certificate envelopes.
Version 0.7.0 is an unpublished source candidate implementing the proposed BRC-202/203 profiles. It removes the mutable DID adapter and old VC/VP proof wrappers. See the identity/DID/VC migration guide before upgrading. Proposed extensions are unregistered; generic W3C conformance and deployed interoperability are not claimed.
npm install @bsv/simple @bsv/sdkimport { createWallet } from '@bsv/simple/browser'
const wallet = await createWallet()
const recipientIdentityKey = '025706528f0f6894b2ba505007267ccff1133e004452a1f6b72ac716f246216366'
// Send a payment via MessageBox P2P
const result = await wallet.pay({
to: recipientIdentityKey,
satoshis: 1000
})
console.log('Paid:', result.txid)did:key identifiers and resolve offlineconst balance = await wallet.getBalance()
console.log(`Balance: ${balance.totalSatoshis} satoshis`)
// Per-basket balance
const tokenBalance = await wallet.getBalance('tokens')
console.log(`Spendable: ${tokenBalance.spendableSatoshis}`)// Register identity handle
await wallet.certifyForMessageBox('@alice', '/api/identity-registry')
// Find recipient and send payment
const results = await wallet.lookupIdentityByTag('bob', '/api/identity-registry')
await wallet.sendMessageBoxPayment(results[0].identityKey, 1000)const recipientIdentityKey = '025706528f0f6894b2ba505007267ccff1133e004452a1f6b72ac716f246216366'
// Create token
const token = await wallet.createToken({
data: { type: 'loyalty', points: 100 },
basket: 'my-tokens'
})
// List tokens
const tokens = await wallet.listTokenDetails('my-tokens')
// Send token to another key
await wallet.sendToken({
basket: 'my-tokens',
outpoint: tokens[0].outpoint,
to: recipientIdentityKey
})// Server generates payment request
const request = serverWallet.createPaymentRequest({ satoshis: 2000 })
// Browser creates BRC-29 derived transaction
const payment = await browserWallet.sendDirectPayment(request)
// Server receives and internalizes
await serverWallet.receiveDirectPayment({
tx: payment.tx,
senderIdentityKey: payment.senderIdentityKey,
derivationPrefix: payment.derivationPrefix,
derivationSuffix: payment.derivationSuffix,
outputIndex: payment.outputIndex
})teratestnet
routing alongside mainnet, testnet, and local presetsimport { DID } from '@bsv/simple'
// Public specification test value, never a production identity.
const identityKey = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
const identityDid = DID.fromIdentityKey(identityKey)
const resolution = DID.resolve(identityDid)
console.log(resolution.didDocument?.id)wallet.getDID() returns the selected identity key's Multikey document. wallet.resolveDID(did) returns a synchronous offline resolution result. A different key creates a different DID; there is no transaction-based creation, update, rotation, recovery, deactivation, registration, or remote resolver fallback. Certificate revocation does not stop the subject DID resolving.
wallet.acquireCredential(config) and wallet.listCredentials({ certifiers, types }) return authenticated BRC52Envelope values. The acquisition flow verifies export compatibility before modifying wallet certificates. The envelope preserves the original signed binary/ciphertext and exports no stored subject/master keyring.
CredentialIssuer.issueCertificate(subjectKey, schemaId, fields) retains BRC-52 delivery data for the authorized certify endpoint. issuer.issue(...) returns { credential, keyringForSubject }; subject-keyring delivery stays outside the authenticated graph. issuer.verify(envelopeJson) accepts a string or UTF-8 bytes and returns BRC52VerificationResult: verified, verifiedDocument, mediaType, and errors. Display only the verified document, and assess issuer trust, disclosure authorization, holder control, and chain status independently.
issuer.getRevocationRecordStatus(serial) reports local retained or unknown. The generated status handler returns chain status: 'unknown'; use @bsv/did's explicit status API for disabled/current/spent evidence. Existing issuance and hash-lock revocation can perform wallet operations and require application authorization. The retired wrappers and unsigned presentation helpers have no implicit holder-proof replacement.
See the package migration notes for the full old-to-new API map. Historical chain records and wallet storage are retained; transaction DIDs and certificate serials must not be guessed into subject identities.
did:key methodbasket insertion vs wallet payment are mutually exclusive — You cannot use both on the same output in a single transactionif (typeof result === 'string') throw new Error(result)result.tx may be undefined — Check before using for overlay broadcasting@bsv/simple/server, not browsertm_; lookup services with ls_ — The Overlay class enforces these prefixes