Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const argv = Yargs(process.argv.slice(2))
.describe("n", "number of wallets")
.boolean("contract")
.describe("contract", "contract address for contract deployment")
.alias("m", "mnemonic")
.boolean("m")
.describe("m", "generate mnemonic")
.alias("l", "log")
.boolean("l")
.describe("l", "log output to file")
Expand All @@ -46,6 +49,7 @@ if (cluster.isMaster) {
isChecksum: argv.checksum ? true : false,
numWallets: argv.count ? argv.count : 1,
isContract: argv.contract ? true : false,
isMnemonic: argv.mnemonic ? true : false,
log: argv.log ? true : false,
logFname: argv.log ? "VanityEth-log-" + Date.now() + ".txt" : "",
};
Expand Down Expand Up @@ -75,6 +79,7 @@ if (cluster.isMaster) {
input: args.input,
isChecksum: args.isChecksum,
isContract: args.isContract,
isMnemonic: args.isMnemonic,
};
const proc = cluster.fork(worker_env);
proc.on("message", function (message) {
Expand Down Expand Up @@ -105,6 +110,7 @@ if (cluster.isMaster) {
worker_env.input,
worker_env.isChecksum == "true",
worker_env.isContract == "true",
worker_env.isMnemonic == "true",
function () {
process.send({
counter: true,
Expand Down
15 changes: 13 additions & 2 deletions libs/VanityEth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import crypto from "crypto";
import ethUtils from "ethereumjs-util";
import ethWallet from "ethereumjs-wallet";
import bip39 from "bip39";
const path = "m/44'/60'/0'/0/0";
var ERRORS = {
invalidHex: "Invalid hex input",
};
Expand All @@ -8,6 +11,12 @@ var getRandomWallet = function () {
var address = "0x" + ethUtils.privateToAddress(randbytes).toString("hex");
return { address: address, privKey: randbytes.toString("hex") };
};
var getRandomWalletWithMnemonic = function () {
const mnemonic = bip39.generateMnemonic();
const key = ethWallet.hdkey.fromMasterSeed(bip39.mnemonicToSeedSync(mnemonic));
const wallet = ethWallet.default.fromExtendedPrivateKey(key.derivePath(path).privateExtendedKey());
return { address: wallet.getAddressString(), privKey: wallet.getPrivateKeyString(), mnemonic: mnemonic };
};
var isValidHex = function (hex) {
if (!hex.length) return true;
hex = hex.toUpperCase();
Expand All @@ -31,14 +40,16 @@ var getVanityWallet = function (
input = "",
isChecksum = false,
isContract = false,
isMnemonic = false,
counter = function () {}
) {
if (!isValidHex(input)) throw new Error(ERRORS.invalidHex);
input = isChecksum ? input : input.toLowerCase();
var _wallet = getRandomWallet();
const randomWalletFunc = isMnemonic ? getRandomWalletWithMnemonic : getRandomWallet;
var _wallet = randomWalletFunc();
while (!isValidVanityWallet(_wallet, input, isChecksum, isContract)) {
counter();
_wallet = getRandomWallet(isChecksum);
_wallet = randomWalletFunc(isChecksum);
}
if (isChecksum) _wallet.address = ethUtils.toChecksumAddress(_wallet.address);
return _wallet;
Expand Down
Loading