How to use the ethereumjs-wallet.generate function in ethereumjs-wallet

To help you get started, we’ve selected a few ethereumjs-wallet 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 iden3 / iden3js / src / key-container / local-storage-container.js View on Github external
generateKeyRand() {
    if (!this.encryptionKey) {
      // KeyContainer not unlocked
      console.error('Error: KeyContainer not unlocked');
      return undefined;
    }
    const w = ethWallet.generate();
    const privK = w._privKey;
    const address = ethUtil.privateToAddress(privK);
    const addressHex = utils.bytesToHex(address);
    const privKHex = utils.bytesToHex(privK);
    const privKHexEncrypted = kcUtils.encrypt(this.encryptionKey, privKHex);

    this.db.insert(this.prefix + addressHex, privKHexEncrypted);
    return addressHex;
  }
github smartcontractkit / chainlink / integration / apocalypse / config / create-accounts.js View on Github external
function ensureAccounts(personas) {
    // Generate missing accounts
    for (let persona of personas) {
        let wallet
        if (accounts[persona] === undefined) {
            console.log(persona, 'unknown, generating account...')
            wallet = ethwallet.generate()
            // keyfileName = wallet.getV3Filename(new Date().getTime())
        } else {
            wallet = ethwallet.fromV3(JSON.stringify(accounts[persona].keyfile), password)
            console.log(persona, `wallet valid (address: ${wallet.getAddressString()})`)
            // keyfileName = accounts[persona].keyfileName
        }
        accounts[persona] = {
            address: wallet.getAddressString(),
            privkey: wallet.getPrivateKeyString(),
            keyfile: JSON.parse(wallet.toV3String(password)),
            // keyfileName: persona,
        }
    }
    fs.writeFileSync(path.join(accountDirPath(), 'accounts.json'), JSON.stringify(accounts, null, 4))

    // Write keyfiles
github OpenZeppelin / openzeppelin-gsn-provider / test / utils.js View on Github external
function createSignKey() {
  const wallet = generate();
  return {
    privateKey: wallet.privKey,
    address: ethUtil.toChecksumAddress(ethUtil.bufferToHex(wallet.getAddress())),
  };
}
github MyCryptoHQ / MyCrypto / spec / integration / derivationChecker.int.ts View on Github external
function makeWallets(): IFullWallet[] {
  const wallets: IFullWallet[] = [];
  let i = 0;
  while (i < derivationRounds) {
    const privKeyWallet = generate();
    wallets.push(privKeyWallet);
    i += 1;
  }
  return wallets;
}
github MyCryptoHQ / MyCrypto / common / libs / web-workers / workers / generateKeystore.worker.ts View on Github external
worker.onmessage = (event: MessageEvent) => {
  const info: GenerateParameters = event.data;
  const wallet = generate();
  const filename = wallet.getV3Filename();
  const privateKey = wallet.getPrivateKeyString();
  const keystore = wallet.toV3(info.password, { n: info.N_FACTOR });

  worker.postMessage({ keystore, filename, privateKey });
};
github BCNetio / BlockStackWallet / app / Providers / Wallets.js View on Github external
export const generateETHWallet = (keychain = v4()) => {
  const pk = eth.generate();
  return {
    privateKey: pk.getPrivateKeyString(),
    address: pk.getAddressString(),
    wid: v4(),
    alias: generateRandomPair(curNames.ETH),
    type: curNames.ETH,
    created: new Date(),
    readOnly: false,
    balance: 0
  };
};
github ETCDEVTeam / emerald-js / packages / vault / src / providers / memory.ts View on Github external
newAccount(passphrase: string, name: string, description: string, chain: string): Promise {
      const newAccount = Wallet.generate();
      const address = `0x${newAccount.getAddress().toString('hex')}`;
      const accountData = {
        address,
        name,
        description,
        V3: newAccount.toV3(passphrase),
        hidden: false,
        hardware: false,
      };

      this.accounts[chain] = this.accounts[chain] || [];
      this.accounts[chain].push(accountData);

      return Promise.resolve(address);
    }