Vanity Addresses in Solana
Background: "Vanity addresses" are Solana public keys ("addresses") where you can specify a "prefix" to the start of your address.
You'll need a powerful computer/VM as the process of discovering a vanity address is computationally intensive. This example will be done using an Ubuntu 20.04 droplet created on DigitalOcean. The more characters in the prefix, the longer it will take to discover a desired private key. In my testing, it took ~2 hours on a very strong VM to discover a 6-character long prefix. 7 character prefixes or higher will require much more time.
Overview
- Linux setup, Solana SDK installation
- Grind for vanity address
- Import into Sollet
- Extra: Full solana-keygen documentation
1. Linux setup
This example uses an Ubuntu 20.04 VM created on DigitalOcean, with 64GB of RAM, and 32 CPUs. This is the most CPU intensive Droplet that DigitalOcean offers.
We choose the most expensive Droplet, as we will be only using it for roughly 2 hours or less (for 6 character prefixes, or less). This means the vanity address will cost ~$2 to generate, assuming we destroy the Droplet immediately after completion.
Steps
- Install the Solana SDK (guide here https://docs.solana.com/wallet-guide/cli)
- As of 2020-12-19, the latest installation command is as follows:
- sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
- Verify the installation worked by executing the following command
- solana --version
2. Grind for vanity address
Choose a vanity prefix - for this example we will use the name "mike" as a prefix. With the Solana SDK installed from step 1, execute the following command:
solana-keygen grind --starts-with mike:1
Replace the word "mike" with your desired prefix. After some time, you should see a result like this:
Wrote keypair to mikeSLUm3Au9zCdtHUvqVmfXmhEpuL3oUgAsC13ZGTo.json
This example took 56 seconds on the best Droplet that DigitalOcean offers.
3. Import into Sollet
If needed, transfer the .json private key file off of your Droplet. Now that you have created a Solana private key file, you can use it with all normal CLI tools. However, most people will want to import this key into Sollet. We will use Python to convert the bytes in the private key into a string that Sollet can use. Sollet's private key import currently only takes in a Base58 private key string. This guide assumes you have installed Python 3.8 (google for a guide on that).
- Install the following Base58 Python package.
- apt-get install python3-pip
- python3.8 -m pip install base58
- Copy the private key from your .json file to clipboard, to be used in the next step.
- Run the following in Python
import base58privkey = [123,...] # Replace this array with the private key stored on your clipboard.print(base58.b58encode(bytearray(privkey)))
You should see a result like below. I have redacted most of the private key.
Copy the string between the "b" and apostrophe characters. This is the Base58 private key that you will import directly into Sollet.
Navigate to Sollet. Click "Account" in the top right and choose "New Account". Follow the prompt as indicated below. Paste the result from above into the "Import Private Key" field and click "Add".
I can be reached for support on Twitter @skynetcap. Feel free to donate any SOL or any tokens to my public Solana address to keep the articles flowing: skynetDj29GH6o6bAqoixCpDuYtWqi1rm8ZNx1hB3vq.
Enjoy!
4. Extra: Full solana-keygen documentation
solana-keygen-grind
Grind for vanity keypairs
USAGE:
solana-keygen grind [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
--ignore-case Performs case insensitive matches
OPTIONS:
-C, --config <FILEPATH>
Configuration file to use [default: /root/.config/solana/cli/config.yml]
--ends-with <SUFFIX:COUNT>...
Saves specified number of keypairs whos public key ends with the indicated suffix
Example: --ends-with ana:4
SUFFIX type is Base58
COUNT type is u64
--starts-and-ends-with <PREFIX:SUFFIX:COUNT>...
Saves specified number of keypairs whos public key starts and ends with the indicated perfix and suffix
Example: --starts-and-ends-with sol:ana:4
PREFIX and SUFFIX type is Base58
COUNT type is u64
--starts-with <PREFIX:COUNT>...
Saves specified number of keypairs whos public key starts with the indicated prefix
Example: --starts-with sol:4
PREFIX type is Base58
COUNT type is u64
Comments
Post a Comment