A vanity addresses give some amount of human readability to the otherwise random string of letters and numbers known as a Solana wallet address.
If you have ever made a single transaction on the Solana blockchain, there is a very high chance that you have interacted one of these vanity address before. Some of the most well known programs use a vanity address, like these:
- TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA - SPL Token program
- TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb - SPL Token 2022 program
- whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc - Orca Whirlpools
- srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX -
Openbook
- perviously Serum, now better! and more open. and no FTX.
You will notice that each of the account addresses start with some readable words (or portions of them). They are all "Vanity Address".
Technical Deep Dive?
You can read all about how Solana addresses are derived and generated in my technical deep dive on it. Including understanding the "derivation path" used to generate vanity address with the Solana CLI. Pretty interesting stuff 😀
How to generate a vanity addresses
The easiest and most common way to generate vanity addresses is using the Solana CLI. So that is what I will demonstrate here as well.
Install the Solana CLI
If you do not have the Solana CLI already installed and setup on your computer, then you can read my other article on How to Setup and Configure the Solana CLI
Make sure you have the solana-keygen
program installed and functioning by
running:
solana-keygen --version
# output (note the version)
# solana-keygen 1.17.6 (src:61caae6b; feat:3073089885, client:SolanaLabs)
Note the version you have installed. This will be important if you want to generate vanity address for use in web/browser wallets like Phantom or Solflare. More on this in a bit.
Using the solana keygen program, we can grind
for (aka brute-force generate)
new vanity addresses that start with, end with, or starts AND ends with certain
characters.
To see all the options you can use to generate random Solana vanity addresses, look at the help for grind:
solana-keygen grind --help
Unsupported characters
Solana public addresses and transactions function on the base-58 character set. Essentially meaning, there are only 58 possible characters:
- including uppercase A-Z, excluding uppercase
O
andI
(as inOscar
andIndia
) - lowercase letters A-Z, excluding lowercase
l
(as inletter
) - digits 1-9, (which does not include
0
)
These specific letters are excluded from the base-58 character set since they can very easily be mistaken for other characters. And if the wrong character is used, then the blockchain address is completely different!
So when you attempt to generate vanity addresses using one of the 4 unsupported characters, the Solana CLI will kick out an error.
Speed of generating vanity addresses
At the current time, the Solana CLI only supports this brute-force method of generating vanity addresses with all the threads of your computer's CPUs. So the more powerful your CPU is, the less time it will take.
Data point: my average range laptop with an Intel i7, 8 core CPU can generate
1,000,000
private key addresses every ~6.3 seconds
The other big factor of how fast you can generate addresses, is the string match you are looking for. The longer the string match (e.g. 4 characters vs 8 characters) and if you are ignoring letter case or not (e.g. "nick" vs "NicK"), the longer it may take.
The last big factor is if you are attempting to generate the mnemonic phrase or just the private key. Generating the mnemonic phrase will take SIGNIFICANTLY LONGER that without
Data point: the same computer from the data point above can generate 1,000,000
mnemonic phrase addresses every ~15-20 minutes
. A lot longer.
Basic grinding
To start your grind
process searching for an address that starts with a set
string:
solana-keygen grind --starts-with nick:1 --ignore-case
This simple command will run until 1
vanity address is found that starts with
nick
(ignoring the letter case). Simple enough.
Also to note, that once a matching address is found, the private key (in the
form of a byte array) will be saved into your terminal's current working
directory with the file named <GENERATED_PUBKEY>.json
Matching multiple strings
The grind
command also allows you to specify multiple strings you want to
search and match. This is usually a more efficient way to search if you are
looking for more than one possible vanity address.
To search and match multiple strings, simply specify the --starts-with
or
--ends-with
or --starts-and-ends-with
flag (with its value) multiple times.
Like so:
solana-keygen grind --ignore-case --starts-with nick:2 --starts-with burn:2 --ends-with frost:2
This process will continue to run until 2
matches are found for EACH of the
given string comparisons. So in the end, this will eventually generate 6
addresses.
Generate with mnemonic phrase
Use a vanity address in a browser wallet
Like I discussed in my technical deep dive on
how deriving Solana addresses works,
the Solana CLI by default is not setup to generate a mnemonic phrase for an
address to use in a web browser wallet. This is because the derivation path
is
different for the default settings on the CLI and what web browsers wallets
(like Phantom and Solflare) use.
So to use a Solana vanity address in a browser wallet, you must change the
derivation path used in the grind
command.
Vanity with mnemonic and derivation path
Using the --derivation-path
flag will allow you to set a custom derivation
path within the Solana CLI. If you do not specify a custom derivation path, this
flag will use a hardcoded path of m/44'/501'/0'/0'
(which is ready to be used
with both Phantom and Solflare).
As apposed to the default the Solana CLI the derivation path of m/44'/501'
(which is NOT compatible with browser wallets).
solana-keygen grind --use-mnemonic --derivation-path --starts-with nick:1 --no-passphrase
If you want, you can also set a custom derivation path like so:
solana-keygen grind --use-mnemonic --derivation-path m/44/117/0/0 --starts-with nick:1 --no-passphrase
Add your vanity address into your browser wallet
The mnemonic that is output from this command can be input into your browser wallet of choice and will work!
You can then use any of the other grind
flags to customize the vanity
addresses you are looking for, and be more usable on the rest of the Solana
blockchain 🙃
How I generate vanity addresses
The way I like to generate vanity addresses with mnemonics is by creating a
separate grind_keys
folder on my computer. Then outputting the generated
mnemonics to a text file on my computer.
I then send the process' output to a text file (aka the mnemonics) for later use.
Like so:
mkdir grinder_keys && cd grind_keys
mkdir keys && cd keys
solana-keygen grind --no-passphrase --use-mnemonic --derivation-path --ignore-case --starts-with nick:100 --starts-with more:100 >> ../mnemonics.txt
This allows me to simply run the same grind
command every time I start my
computer. Making it so I can generate addresses for longer periods of times,
like days and weeks, on my desktop computer. With no fear of losing the
generated mnemonic.
Then pick-and-chose the best vanity address from the ones it found. Like right
now, I am running it looking for a good nick
address to use on my Solana Saga
Phone (soon) as my new address!