Last active
May 31, 2021 08:05
-
-
Save larry0x/85d91202ba3b89e41736eed0fdfef022 to your computer and use it in GitHub Desktop.
Generate vanity Ethereum addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ethers.js doesn't seem to support generating 24-word mnemonic phrases. Instead, we use | |
// terra.js to generate the phrases, and use ethers to convert them to Ethereum addresses. | |
// | |
// How to use: | |
// | |
// > npm install ethers @terra-money/terra.js | |
// > node generate.js | |
// | |
const { MnemonicKey } = require("@terra-money/terra.js"); | |
const { Wallet } = require("ethers"); | |
const total = 16 ** 6; // How many mnemonic phrases to generate before we give up | |
const criterion = (address) => { | |
if ( | |
address.startsWith("0x000000") || | |
address.startsWith("0x123456") || | |
address.startsWith("0x888888") || | |
address.startsWith("0x999999") | |
) { | |
return true; | |
} | |
return false; | |
}; | |
for (let i = 1; i <= total; i++) { | |
let mk = new MnemonicKey(); | |
let wallet = Wallet.fromMnemonic(mk.mnemonic); | |
console.log(`${i}/${total} ${wallet.address}`); | |
if (criterion(wallet.address)) { | |
console.log("Found it!"); | |
console.log("Mnemonic:", mk.mnemonic); | |
process.exit(0); | |
} | |
} | |
console.log("No result found :("); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment