ReferenceAdapters
WebCryptoSignerAdapter
Persistent Secp256r1 keys generated via the Web Crypto API and stored in IndexedDB
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:
pnpm add @mysten/signersUsage
import { WebCryptoSignerAdapter } from '@mysten-incubation/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.