Skip to content

Instantly share code, notes, and snippets.

@theJohnnyBrown
Created August 2, 2025 18:31
Show Gist options
  • Select an option

  • Save theJohnnyBrown/ca082d6ca9264c2b85702bcfecc24295 to your computer and use it in GitHub Desktop.

Select an option

Save theJohnnyBrown/ca082d6ca9264c2b85702bcfecc24295 to your computer and use it in GitHub Desktop.

Solana Keypairs

Generate a Solana keypair along with a seed phrase:

➜  tmp solana-keygen new --outfile tmp1.json --no-bip39-passphrase

Generating a new keypair
Wrote new keypair to tmp1.json
====================================================================
pubkey: eC86BRbWX6rmqv5d4AWQ22DLKxbXeaPZ4nZDn6xWqcM
====================================================================
Save this seed phrase to recover your new keypair:
okay prison law quantum kiwi blouse when thumb rapid cover end vapor
====================================================================
➜  tmp

This saves the private key to tmp1.json and shows the corresponding public key. It also shows a seed phrase which can be used to recover the public/private keypair

Recover the generated private key from the public key

➜  tmp solana-keygen recover ASK --outfile recover.json
[recover] seed phrase:
[recover] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
Recovered pubkey `"eC86BRbWX6rmqv5d4AWQ22DLKxbXeaPZ4nZDn6xWqcM"`. Continue? (y/n):
y
Wrote recovered keypair to recover.json
➜  tmp diff recover.json tmp1.json
➜  tmp

Interaction with web wallets

If you import the seed phrase into e.g. Phantom wallet, you will get a different wallet address than the one above. That keypair can be recovered like this:

➜  tmp solana-keygen recover "prompt://?full-path=m/44/501'/0'/0'" --outfile recover-web.json
[recover] seed phrase:
[recover] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
Recovered pubkey `"2xdXy3LCbg2ixsTU8eMcTQoV9pDReS6GANniVirjGdXy"`. Continue? (y/n):
y
Wrote recovered keypair to recover-web.json

This will use a different "derivation path" from the seed phrase to derive the public/private key.

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