@cfxdevkit/core / EmbeddedWalletManager
Class: EmbeddedWalletManager
Defined in: packages/core/src/wallet/embedded/custody.ts:66
Embedded Wallet Manager
Manages server-side custody wallets for users. Provides secure wallet creation, storage, and transaction signing.
SECURITY WARNING: This is a simplified implementation for development and testing. Production use requires:
- Hardware Security Modules (HSM)
- Proper key management infrastructure
- Multi-signature schemes
- Audit logging
- Compliance with custody regulations
Use Cases:
- Social login wallets (Privy, Magic, Web3Auth)
- Custodial game wallets
- Enterprise treasury management
- Automated service accounts
Example
const manager = new EmbeddedWalletManager();
// Create wallet for user
const wallet = await manager.createWallet('user123', 'secure-password');
// Sign transaction
const signed = await manager.signTransaction('user123', 'secure-password', {
to: '0xRecipient...',
value: parseEther('1.0'),
chain: 'evm'
});
// Export wallet for user
const exportData = await manager.exportWallet('user123', 'secure-password');Constructors
Constructor
new EmbeddedWalletManager(
options?):EmbeddedWalletManager
Defined in: packages/core/src/wallet/embedded/custody.ts:70
Parameters
options?
Returns
EmbeddedWalletManager
Methods
createWallet()
createWallet(
userId,password):Promise<Omit<EmbeddedWallet,"encryptedPrivateKey">>
Defined in: packages/core/src/wallet/embedded/custody.ts:85
Create a new embedded wallet for a user
Parameters
userId
string
User identifier
password
string
Encryption password
Returns
Promise<Omit<EmbeddedWallet, "encryptedPrivateKey">>
Created wallet (without private key)
deactivateWallet()
deactivateWallet(
userId):void
Defined in: packages/core/src/wallet/embedded/custody.ts:266
Deactivate wallet
Parameters
userId
string
User identifier
Returns
void
deleteWallet()
deleteWallet(
userId):boolean
Defined in: packages/core/src/wallet/embedded/custody.ts:281
Delete wallet permanently
WARNING: This operation cannot be undone
Parameters
userId
string
User identifier
Returns
boolean
true if deleted, false if not found
exportWallet()
exportWallet(
userId,password):Promise<WalletExport>
Defined in: packages/core/src/wallet/embedded/custody.ts:229
Export wallet for user backup
Parameters
userId
string
User identifier
password
string
Encryption password
Returns
Promise<WalletExport>
Encrypted wallet export
getStats()
getStats():
object
Defined in: packages/core/src/wallet/embedded/custody.ts:302
Get wallet statistics
Returns
object
Wallet statistics
active
active:
number=active.length
inactive
inactive:
number
total
total:
number=all.length
getWallet()
getWallet(
userId):Omit<EmbeddedWallet,"encryptedPrivateKey"> |undefined
Defined in: packages/core/src/wallet/embedded/custody.ts:141
Get wallet info (without private key)
Parameters
userId
string
User identifier
Returns
Omit<EmbeddedWallet, "encryptedPrivateKey"> | undefined
Wallet info or undefined
hasWallet()
hasWallet(
userId):boolean
Defined in: packages/core/src/wallet/embedded/custody.ts:158
Check if user has a wallet
Parameters
userId
string
User identifier
Returns
boolean
true if wallet exists
listWallets()
listWallets():
Omit<EmbeddedWallet,"encryptedPrivateKey">[]
Defined in: packages/core/src/wallet/embedded/custody.ts:290
List all wallets (without private keys)
Returns
Omit<EmbeddedWallet, "encryptedPrivateKey">[]
Array of wallet info
signTransaction()
signTransaction(
userId,password,request):Promise<SignedTransaction>
Defined in: packages/core/src/wallet/embedded/custody.ts:170
Sign transaction with user’s embedded wallet
Parameters
userId
string
User identifier
password
string
Decryption password
request
Transaction request
Returns
Promise<SignedTransaction>
Signed transaction