createNew static method

Future<String> createNew(
  1. Credentials credentials,
  2. String password,
  3. Random random, {
  4. bool useScrypt = true,
  5. int? n,
  6. int? r,
  7. int? p,
})

Creates a Keystore V3 wallet JSON from the credentials.

Implementation

static Future<String> createNew(
  Credentials credentials,
  String password,
  Random random, {
  bool useScrypt = true,
  int? n,
  int? r,
  int? p,
}) async {
  final pk = credentials.privateKey;
  final address = credentials.address.hex;
  final json = crypto.KeystoreV3.encrypt(
    pk,
    password,
    useScrypt: useScrypt,
    address: address,
    n: n,
    r: r,
    p: p,
  );
  return jsonEncode(json);
}