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 @@ -25,6 +25,9 @@ const argv = Yargs(process.argv.slice(2))
.alias("i", "input")
.string("i")
.describe("i", "input hex string")
.alias("j", "input2")
.string("j")
.describe("j", "input hex string")
.alias("c", "checksum")
.boolean("c")
.describe("c", "check against the checksum address")
Expand All @@ -43,6 +46,7 @@ const argv = Yargs(process.argv.slice(2))
if (cluster.isMaster) {
const args = {
input: argv.input ? argv.input : "",
input2: argv.input2 ? argv.input2 : "",
isChecksum: argv.checksum ? true : false,
numWallets: argv.count ? argv.count : 1,
isContract: argv.contract ? true : false,
Expand Down Expand Up @@ -73,6 +77,7 @@ if (cluster.isMaster) {
for (let i = 0; i < numCPUs; i++) {
const worker_env = {
input: args.input,
input2: args.input2,
isChecksum: args.isChecksum,
isContract: args.isContract,
};
Expand Down Expand Up @@ -103,6 +108,7 @@ if (cluster.isMaster) {
process.send({
account: VanityEth.getVanityWallet(
worker_env.input,
worker_env.input2,
worker_env.isChecksum == "true",
worker_env.isContract == "true",
function () {
Expand Down
11 changes: 7 additions & 4 deletions libs/VanityEth.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,32 @@ var isValidHex = function (hex) {
var re = /^[0-9A-F]+$/g;
return re.test(hex);
};
var isValidVanityWallet = function (wallet, input, isChecksum, isContract) {
var isValidVanityWallet = function (wallet, input, input2, isChecksum, isContract) {
var _add = wallet.address;
if (isContract) {
var _contractAdd = getDeterministicContractAddress(_add);
_contractAdd = isChecksum
? ethUtils.toChecksumAddress(_contractAdd)
: _contractAdd;
wallet.contract = _contractAdd;
return _contractAdd.substr(2, input.length) == input;
return _contractAdd.substr(2, input.length) == input
&& (!input2 || _contractAdd.substr(-input2.length) == input2);
}
_add = isChecksum ? ethUtils.toChecksumAddress(_add) : _add;
return _add.substr(2, input.length) == input;
return _add.substr(2, input.length) == input
&& (!input2 || _add.substr(-input2.length) == input2);
};
var getVanityWallet = function (
input = "",
input2 = "",
isChecksum = false,
isContract = false,
counter = function () {}
) {
if (!isValidHex(input)) throw new Error(ERRORS.invalidHex);
input = isChecksum ? input : input.toLowerCase();
var _wallet = getRandomWallet();
while (!isValidVanityWallet(_wallet, input, isChecksum, isContract)) {
while (!isValidVanityWallet(_wallet, input, input2, isChecksum, isContract)) {
counter();
_wallet = getRandomWallet(isChecksum);
}
Expand Down