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);
}
@ffunotface
Copy link

How output node vanity.js TERM PASSWORD is different from node vanity.js TERM? Where is that password? And how to import with this password to have desirable public address?

@baketzforme
Copy link
Author

The 15 word seed phrase generates a different address with a password than without one. The password is optional and can be whatever you choose it to be.

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.

To import this wallet, you would use the command-line octez-client (previously called tezos-client) binary, entering the command octez-client import fundraiser secret key <alias> (where <alias> can be any name you choose). It will then ask for an email address, which you should leave blank (just press enter). It will then ask for the seed phrase, one word at a time. Then it will ask for the password. Once you have entered all the information, it will display a public address and ask you to verify that it is the address you expect.

@Vishona
Copy link

Vishona commented Nov 7, 2023

Hello! Hope you are well and taking it easy!
Thanks so much for this, it has been very useful and fun!
We were wondering how to adjust resources to be used in generation?
Thank you for any help!
<3.14

@Vishona
Copy link

Vishona commented Nov 10, 2023

After 2.5 days of generating 4 instances, We received a 5 character address.
When importing to Temple wallet it gave Us a different address.
Only then did we see your above comment.
Do How exactly do we run that? along with the other code?
Thank you for any help!
<3.14

@baketzforme
Copy link
Author

baketzforme commented Nov 10, 2023

I no longer recommend using this tool to generate a vanity address, due to the difficulty of importing the address into modern wallets.

We were wondering how to adjust resources to be used in generation?

Sorry, I don't know how to adjust resources used. As far as I know, it will use a single thread and work as fast as it can on that thread. You can run the command multiple times simultaneously if you want it to use multiple threads (one thread per command).

After 2.5 days of generating 4 instances, We received a 5 character address. When importing to Temple wallet it gave Us a different address. Only then did we see your above comment. Do How exactly do we run that? along with the other code?

octez-client can be built from Octez source code, or you can download static binaries. Both of which can be found in the official repository: https://gitlab.com/tezos/tezos/-/releases

@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