initialize method

Future<String?> initialize({
  1. String? mnemonic,
  2. String network = 'mainnet',
})

Initializes new hierarchical deterministic wallet or restores one from given mnemonic.

Returns the used mnemonic. If the wallet should be used with did:eth and on another ethereum-network than the mainnet, pass the nme or its id as network.

Implementation

Future<String?> initialize(
    {String? mnemonic, String network = 'mainnet'}) async {
  var mne = mnemonic;
  if (mnemonic == null) {
    mne = generateMnemonic();
  }
  var seed = mnemonicToSeed(mne!);

  await _keyBox!.put('seed', seed);
  await _keyBox!.put('lastCredentialIndex', 0);
  await _keyBox!.put('lastConnectionIndex', 0);
  await _keyBox!.put('lastCredentialIndexEd', 0);
  await _keyBox!.put('lastConnectionIndexEd', 0);
  await _keyBox!.put('lastConnectionIndexX', 0);
  await _configBox!.put('network', network);

  return mne;
}