Restoring CLI wallet from mnemonic


I created a Solana wallet in CLI and I have the mnemonic. However, I created a new wallet and the id.json file was overwritten. Now, I have the mnemonic but I have nothing else to restore the wallet with as there are funds in it.

How do I restore the wallet with only the phrase? Importing into phantom does not work.

1 Like

Hi @solkarens and welcome to the forum! :wave:

You can restore the CLI wallet using the seed phrase like so:

solana-keygen recover ASK

By default this will replace your existing id.json file, but you can also tell it to put the generated key in a different file like so:

solana-keygen recover ASK -o my_key.json
1 Like

Hello, I have tried this out and it returns a different address than what I originally was given. Also, it asks me for a passphrase if applicable. I dont believe that I set one, but if I did, does that return me a different wallet?


If you had a passphrase, that would return a different wallet with one.

You can also try this instead:

solana-keygen recover prompt://

Hello, I do not believe I set a pass but its returning a different wallet. What gives?

So, for any one seed phrase, you can actually generate an almost unlimited number of different wallets, each with what they call a derivation path.

When you say recover ASK it generates a wallet with the “master” derivation path: m. When you do recover prompt:// it uses a different derivation path: m/44'/501', which will give you a different wallet.

When you run solana-keygen new it will generate a master wallet from the seed phrase, so you should be able to get it back with solana-keygen recover ASK.

If you specified a passphrase when you ran solana-keygen new, you will need to specify the same passphrase, or you will get a different wallet address.

It’s all kind of confusing.

Hello, thanks for the help so far. I tried running solana-keygen recover ASK and it is still giving me a different ‘master’ wallet. I dont think there is a password on it, is there any way to export the mnemonic to an online portal in order to get it to work?

Or any other solutions?
best regards

What version of the Solana CLI do you have, just for reference? Maybe the default derivation path changed.

Otherwise, you could try restoring your wallet in, but if you generated the wallet on the Solana CLI, then it probably won’t work.

I’m pretty sure you’ve probably either got the seed phrase wrong, or you are missing the passphrase, because I think that recover ASK should have worked. Just double-check everything.

:warning:Warning: Always be super suspicious BTW when somebody gives you a link to a wallet, like I just did. It’s a common trick by scammers to send you to put your seed phrase into a fake wallet app.

You can check that my link is legit on the GitHub page for Sollet: GitHub - project-serum/spl-token-wallet

solana-cli 1.9.6 (src:781609b2; feat:2191737503)

the seed phrase I directly copied and pasted with the whole text it gives about saving it.

I just tried Solana CLI version 1.9.4 ( older than yours ) and 1.9.14 ( newer than yours ) and it both cases, I am able to run solana-keygen new and then take the seed phrase that it ouputs and recover the same wallet with solana-keygen recover ASK, so I’m not sure why it’s not working. :confused:

You should be able to do the same thing with your CLI to test:

$ solana-keygen new -o /tmp/key3.json
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): 

Wrote new keypair to /tmp/key3.json
pubkey: 4kuXHjrRWYNJZZwr5EcJdGXgkRApSv14H2ryG6R5XcmL
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
invite tackle depth calm clump worry toward fog parade aware offer rack

$ solana-keygen recover ASK -o /tmp/key4.json
[recover] seed phrase: 
[recover] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue: 
Recovered pubkey `4kuXHjrRWYNJZZwr5EcJdGXgkRApSv14H2ryG6R5XcmL`. Continue? (y/n): y
Wrote recovered keypair to /tmp/key4.json

Both /tmp/key3.json and /tmp/key4.json will have the same contents.

Maybe try some different ideas you might have for what the passphrase could have been if you would have set one?

Just to make sure, when you use the recover command you are leaving the pass phrase completely blank and just pushing enter to skip that part, and you are only putting in the 12 seed words separated by a space when it asks for your seed phrase?

1 Like