How to use the ethers.Wallet.createRandom function in ethers

To help you get started, we’ve selected a few ethers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hubiinetwork / nahmii-contracts / test / mocks.js View on Github external
exports.mockPayment = async (operator, params) => {
    const senderWallet = Wallet.createRandom();
    const recipientWallet = Wallet.createRandom();

    const payment = exports.mergeDeep({
        amount: utils.parseUnits('100', 18),
        currency: {
            ct: exports.address1,
            id: utils.bigNumberify(0)
        },
        sender: {
            wallet: senderWallet.address,
            nonce: utils.bigNumberify(1),
            balances: {
                current: utils.parseUnits('9399.8', 18),
                previous: utils.parseUnits('9500', 18)
            },
            fees: {
                single: {
github hubiinetwork / nahmii-contracts / test / scenarios / NullSettlementState.js View on Github external
before(async () => {
                    address = Wallet.createRandom().address;
                });
github Arianee / arianeeJS / src / core / wallet / walletBuilder.ts View on Github external
public fromRandomKey (): ArianeeWallet {
    const randomWallet = etherWallet.createRandom();
    const mnemonic = randomWallet.mnemonic;
    const account = this.web3.eth.accounts.privateKeyToAccount(
      randomWallet.privateKey
    );

    return this.buildAriaWalletFrom({ account, mnemonic });
  }
github ConnextProject / indra / modules / cf-core / src / private-keys-generator.ts View on Github external
}

  if (publicExtendedKey && privateKeyGenerator) {
    return Promise.resolve([
      new PrivateKeysGetter(privateKeyGenerator),
      publicExtendedKey
    ]);
  }

  let extendedPrvKey = await storeService.get(EXTENDED_PRIVATE_KEY_PATH);

  if (!extendedPrvKey) {
    log.info(
      "No (extended public key, private key generation function) pair was provided and no extended private key was found in store. Generating a random extended private key"
    );
    extendedPrvKey = fromMnemonic(Wallet.createRandom().mnemonic).extendedKey;
    await storeService.set([
      { path: EXTENDED_PRIVATE_KEY_PATH, value: extendedPrvKey }
    ]);
  } else {
    log.info("Using extended private key found in the store.");
  }
  const [
    privKeyGenerator,
    extendedPubKey
  ] = generatePrivateKeyGeneratorAndXPubPair(extendedPrvKey);
  return Promise.resolve([
    new PrivateKeysGetter(privKeyGenerator),
    extendedPubKey
  ]);
}
github unlock-protocol / unlock / unlock-js / src / accounts.js View on Github external
export async function createAccountAndPasswordEncryptKey(password) {
  const newWallet = Wallet.createRandom()
  const address = await newWallet.getAddress()
  const passwordEncryptedPrivateKey = JSON.parse(
    await newWallet.encrypt(password, walletEncryptionOptions)
  )

  return {
    address,
    passwordEncryptedPrivateKey,
  }
}