Skip to content

Instantly share code, notes, and snippets.

@baketzforme
Last active November 10, 2023 19:28
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save baketzforme/e27d46d70e949ea9953b11902c2fa4fe to your computer and use it in GitHub Desktop.
Save baketzforme/e27d46d70e949ea9953b11902c2fa4fe to your computer and use it in GitHub Desktop.
Tezos Vanity Address with Seed Phrase

WARNING: Vanity addresses generated with this tool may not be widely supported in various wallets anymore. They may consider the addresses generated with this tool to be "legacy" wallets. Therefore I no longer recommended generating vanity addresses using this method.

After seeing the recently posted How To Generate A Tezos Vanity Address, I thought I'd share a method I've used to generate a vanity address that has the benefit of being able to easily be restored or transferred to another wallet from a seed phrase backup.

Most of the credit goes to Stephen Andrews. I've just slightly modified some of the code he wrote to get it to work the way I want.

Everything below assumes you are working from the Linux command line (tested in Debian/Ubuntu distributions):

First, clone Stephen Andrews' eztz repository from github:

git clone -b vanity https://github.com/stephenandrews/eztz

Then enter the newly created directory and the vanity subdirectory:

cd eztz/vanity

Next, install the needed dependencies with npm (use apt install npm if you don't have npm installed):

npm install

Grab my customized index.js which I called vanity.js here:

wget https://gist.github.com/baketzforme/e27d46d70e949ea9953b11902c2fa4fe/raw/vanity.js

Finally you're ready to generate your vanity address. The below example will search for an address that starts with tz1TERM.

node vanity.js TERM

Example output:

node vanity.js Tz  
Searching for tz1Tz  
Checked 119 hashes  
Found match:  
tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8  
giant grunt jewel suit scatter surface chaos tumble radar fortune rifle frost essence motion worry  

You can also optionally include a password. This adds a little more security because the seed words without the password will not import the same address.

node vanity.js TERM PASSWORD

Example output:

node vanity.js Tz secretPassword  
Searching for tz1Tz  
Checked 630 hashes  
Found match:  
tz1TzijVFZT1QmohdSfsBnVAQQa48eWL2xfH  
ramp sea drama balance scale mixed chapter dream hundred sweet language chuckle reform alert clock  

The above seed phrase without the password generates the following address: tz1aBFAMsDGHqnmrhgGhjx9kowjFLJMXEbsC

Just make sure to backup your seed phrase and your password if you use one, or else any funds stored on the generated account could be lost forever.

Enjoy!

#!/usr/bin/env node
const _sodium = require('libsodium-wrappers');
(async() => {
if (process.argv.length <= 2){
console.log("Please enter a term to find, with an optional password, e.g. node vanity.js test [password]");
return;
}
var match = process.argv[2];
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
for(var i = 0; i < match.length; i++){
if (ALPHABET.indexOf(match[i]) < 0){
console.log("Your search term is not valid - please ensure search term only includes b58 valid characters: " + ALPHABET);
return;
}
}
await _sodium.ready;
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var ee = require("./main.js");
var eztz = ee.eztz;
eztz.library.sodium = _sodium;
var keys, fmatch = "tz1" + match;
console.log("Searching for " + fmatch);
var cc = 0;
function tick() {
m = eztz.crypto.generateMnemonic();
if (process.argv.length > 2) {
keys = eztz.crypto.generateKeys(m, process.argv[3]);
} else {
keys = eztz.crypto.generateKeys(m);
}
if (keys.pkh.substr(0, fmatch.length) == fmatch){
console.log("\nFound match:");
console.log(keys.pkh);
console.log(m);
} else {
printProgress("Checked " + cc++ + " hashes");
setImmediate(tick);
}
}
tick();
})();
function printProgress(progress){
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(progress);
}
@Vishona
Copy link

Vishona commented Nov 10, 2023

Thank you very much for your work, your help, and your quick reply and update.
You are awesome, please take it easy!
<3.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment