Nono.MA

OCTOBER 10, 2022

Here's how to obtain a Solana account from a seed phrase.

Before we get into the actual commands, I'll clarify a few concepts.

  • Solana accounts are usually referred to as keypairs. To own an account, you need both its public and private keys, its key pair, which allows you to receive and sign transactions
  • Solana provides a key generation tool to derive keys from BIP39-compliant seed phrases1
  • Using the solana-keygen tool, it is possible to generate new seed phrases as well as derive a keypair from an existing seed phrase and (optional) passphrase1
  • A seed phrase is composed of 12 common words following BIP 392
  • A passphrase is effectively a password

This is what a 12-word Solana seed phrase looks like.

wish fatal benefit theory scheme burger scale guess switch chair cotton luggage

And this is what one of its corresponding accounts looks like. Specifically, I'm showing the seed phrase with an empty passphrase, which is not recommended as a good passphrase adds one more layer of security to your account.

CnEho7Diwmdf9pMMmFqhwwYxL4DWMwsHQ9jV2qNqPKcg

From seed phrase to Solana account

As stated above, Solana provides the solana-keygen command-line interface to derive keypairs from existing seed phrases and (optional) passphrases. This can be done with the pubkey command.

solana-keygen pubkey ASK
  • [pubkey recovery] seed phrase: Introduce your 12 words here
  • [pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue: Introduce the passphrase of your account here

You should then obtain a Solana account that you can look at in Solana's explorer.

Creating a Solana account

Let's create a new keypair—seed phrase and passphrase—and then derive it with solana-keygen.

The solana-keygen new command will save the key at ~/config/solana/id.json. You can use the --no-outfile to only outputting your key on screen.

solana-keygen new --no-outfile

When prompted for a passphrase (twice), I used the following string.

SomeSafeP4ssw0rdHere@97vmJ!9!7721
# Generating a new keypair
# 
# For added security, enter a BIP39 passphrase
# 
# NOTE! This passphrase improves security of the recovery seed phrase NOT the
# keypair file itself, which is stored as insecure plain text
# 
# BIP39 Passphrase (empty for none): 
# Enter same passphrase again: 
# 
# ============================================================================
# pubkey: 4WXWzSAzPWLs7M5vMGzcZP3puKQGTCVyWXtYEQaJKP1a
# ============================================================================
# Save this seed phrase and your BIP39 passphrase to recover your new keypair:
# decade can extra easy copy talk monkey meat buddy crash glue lift
# ============================================================================

Here, the account is 4WXWzSAzPWLs7M5vMGzcZP3puKQGTCVyWXtYEQaJKP1a, which can be browsed in Solana's explorer.

If you omit the --no-outfile flag, solana-keygen will save your key pair as a JSON array at ~/config/solana/id.json in the format shown below. You can also specify the -o flat to provide a custom path for the JSON key pairs to be saved.

solana-keygen new -o ~/Desktop/keypair.json
// keypair.json
[49,21,188,192,1,119,112,63,145,159,153,136,201,251,34,120,155,24,35,79,187,18,54,109,196,59,155,28,32,45,35,190,132,136,69,221,208,223,184,50,3,123,157,23,248,183,98,232,226,66,205,114,148,137,240,157,79,214,127,224,101,118,159,65]

Recovering a Solana account

We've created the 4WXWzSAzPWLs7M5vMGzcZP3puKQGTCVyWXtYEQaJKP1a account, and we have its seed phrase and passphrase. If we move to a new machine or somehow lost our keys, here's how to recover (or derive) them.

solana-keygen pubkey ASK

# Feed seed phrase when prompted
decade can extra easy copy talk monkey meat buddy crash glue lift

# Feed passphrase when prompted
SomeSafeP4ssw0rdHere@97vmJ!9!7721

# Derived account
4WXWzSAzPWLs7M5vMGzcZP3puKQGTCVyWXtYEQaJKP1a

For more information, Read Solana's Paper Wallet documentation.

My Solana address

In case you want to send a token of appreciation my way, here's my Solana address. =)

GF14Kk1Deh7BjjxBUR9zSgV47EKuZNmb8eRcmaDxjbX9

  1. Paper Wallet. Solana.  

  2. BIP-39 describes how to generate a 512-bit seed from the seed phrase. Abiraja

Want to see older publications? Visit the archive.

Listen to Getting Simple .