create static method

Future<Wallet> create(
  1. Uint8List? seed, {
  2. required WalletConfig config,
})

create creates a wallet from an account and an optional config. For any zero value field in config, the default wallet config value will be used. If config is nil, the default wallet config will be used. However, it is strongly recommended to use non-empty password in config to protect the wallet, otherwise anyone can recover the wallet and control all assets in the wallet from the generated wallet JSON.

Implementation

static Future<Wallet> create(Uint8List? seed,
    {required WalletConfig config}) async {
  try {
    final Map data = await _methodChannel.invokeMethod('create', {
      'seed': seed,
      'password': config.password,
      'seedRpc': config.seedRPCServerAddr?.isNotEmpty == true
          ? config.seedRPCServerAddr
          : [DEFAULT_SEED_RPC_SERVER],
    });
    Wallet wallet = Wallet(walletConfig: config);
    wallet.keystore = data['keystore'];
    wallet.address = data['address'];
    wallet.seed = data['seed'];
    wallet.publicKey = data['publicKey'];
    return wallet;
  } catch (e) {
    rethrow;
  }
}