ReferenceAdapters
WebCryptoSignerAdapter
Generates Secp256r1 key pairs via the browser's Web Crypto API and persists them in IndexedDB. Keys survive page reloads and browser restarts.
Requires the @mysten/signers peer dependency:
npm i @mysten/signersUsage
import { WebCryptoSignerAdapter } from '@mysten/dev-wallet/adapters';
const adapter = new WebCryptoSignerAdapter();
await adapter.initialize(); // Loads existing keys from IndexedDB
// Create a new persistent account
const account = await adapter.createAccount({ label: 'Persistent Dev' });The constructor accepts optional dbName and storeName to control which IndexedDB database is
used (defaults: 'dev-wallet-webcrypto' and 'accounts').
How Persistence Works
- When you create an account, a non-extractable
CryptoKeyPairis generated viacrypto.subtle.generateKey() - The key pair and metadata are stored in an IndexedDB database (
dev-wallet-webcrypto) - On
initialize(), all stored key pairs are loaded back - Private keys never leave the browser's crypto engine — they cannot be exported to JavaScript
API
| Property / Method | Description |
|---|---|
id | 'webcrypto' |
name | 'WebCrypto Signer' |
allowAutoSign | Not set (auto-sign allowed) |
initialize() | Load keys from IndexedDB |
createAccount(options?) | Generate a new Secp256r1 key pair |
removeAccount(address) | Remove account and delete from IndexedDB |
renameAccount(address, label) | Update label (persisted) |
getAccounts() | List all managed accounts |
getAccount(address) | Look up a single account |
onAccountsChanged(callback) | Subscribe to account list changes |
destroy() | Clean up listeners and state |
Requirements
- Secure context (HTTPS or localhost)
- Browser with Web Crypto API support (all modern browsers)
- IndexedDB available (not in some worker contexts)
Keys do not survive incognito/private browsing sessions or clearing site data. For truly
persistent development keys, use the Remote CLI
adapter with your sui keystore.