createDaccWallet_V2
The createDaccWallet_V2 function is the V2 version of createDaccWallet. Its primary role is to generate a new wallet, encrypt its Private Key using the user's password with configurable encryption strength, and return the wallet's public address along with the encrypted key for secure storage. Compared to V1, this version introduces the encryptMode parameter for controlling encryption speed and security.
Import
import { createDaccWallet_V2 } from 'dacc-js';Usage
import { createDaccWallet_V2 } from 'dacc-js';
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'my+Password#123..',
encryptMode: 'medium',
// publicEncryption: true,
// dataStorageNetwork: 'opSepolia',
// pkWalletForSaveData: 'ENV.0XPRIVATEKEY_GAS..',
// minPassword: 24
});
console.log("wallet:", wallet); // {address, daccPublickey}
console.log("wallet address:", wallet?.address); // 0x123address... (recall)
console.log("wallet daccPublickey:", wallet?.daccPublickey); // daccPublickeyV2_XxX... (keep)Arguments
| Parameter | Type | Description |
|---|---|---|
passwordSecretkey | string | The user's password used as the key for encryption. |
publicEncryption | boolean | Enable or disable public encryption (default: false). default: false, no retrospective recording will be performed with readDaccWallet. |
dataStorageNetwork | string (keyof) - SELECT or customChain{} | The blockchain network (e.g., 'opSepolia') to store the encrypted data is on-chain. |
pkWalletForSaveData | 0x${string} | The Private Key of an existing wallet used to pay for gas when submitting the encrypted data to the blockchain (required if dataStorageNetwork is set). |
minPassword, maxPassword | number | Optional settings to define the minimum/maximum password length (defaults: 12 and 120). |
encryptMode | 'down' | 'low' | 'fast' | 'medium' | 'high' | Optional: Encryption speed/security preset (default: medium). |
Return Value
The response result is an object containing. {address, daccPublickey}
Parameters
passwordSecretkey
- Type:
string
You set a password.
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'myPassword#123...',
});encryptMode (optional)
- Type:
'down'|'low'|'fast'|'medium'|'high' - Default:
'medium'
Encryption speed and security preset. Higher modes provide stronger encryption but are slower to compute.
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'my+Password#123...',
encryptMode: 'fast',
});publicEncryption (optional)
- Type:
boolean - Default:
false
Configure the public encryption mode setting.
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'my+Password#123...',
publicEncryption: true // default = false
dataStorageNetwork: 'opSepolia', // required for this mode
pkWalletForSaveData: 'ENV.0XPRIVATEKEY_GAS...' // required for this mode
});dataStorageNetwork (optional)
- Type:
string(keyof) |customChain{ chain: Chain, contract: 0x${string}}
Select supported networks.
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'myPassword#123...',
publicEncryption: true, // required for this mode
dataStorageNetwork: 'opSepolia',
// dataStorageNetwork: {
// customChain: { // For Custom Chain Network
// chain: myCustomChain,
// contract: "0xYourDeployDaccWalletStorageOnChainAddress..",
// },
// },
pkWalletForSaveData: 'ENV.0XPRIVATEKEY_GAS...', // required for this mode
});pkWalletForSaveData (optional)
- Type:
0x${string}
Specify a private key for the wallet creation to save the public key encryption data retrospectively.
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'myPassword#123...',
dataStorageNetwork: 'opSepolia',
pkWalletForSaveData: 'ENV.0XPRIVATEKEY_GAS..', // ENV.SECRET
});minPassword & maxPassword (optional)
- Type:
number - Default:
12(min),120(max)
Configure the password length setting.
const wallet = await createDaccWallet_V2({
passwordSecretkey: 'myPassword#123',
// publicEncryption: true,
// dataStorageNetwork: 'opSepolia',
// pkWalletForSaveData: '0xprivatekeyGas..',
minPassword: 24 // default = 12
maxPassword: 240 // default = 120
});