Using a Phantom Wallet Address with the Solana CLI

I’m learning about Solana and wanted to try accessing the address I set up with Phantom via the Solana CLI.

For anyone Googling how to accomplish this, here are the steps I used:

Install the Solana CLI

First you’ll need to install the Solana CLI.

Note that the installation script assumed I was using Bash and added the Solana CLI to Bash’s PATH variable, but my Mac is using the Z Shell (zsh), so I had to manually add the Solana CLI to the Z Shell PATH variable:

vi ~/.zshrc 
export PATH="/Users/matt/.local/share/solana/install/active_release/bin:$PATH"

Generate a File System Wallet

From the command line, run:

$ solana-keygen recover 'prompt:?key=0/0' --outfile ~/.config/solana/id.json

This will prompt for your Secret Recovery Phrase (which you can access through the Phantom Wallet’s settings). Enter it and when prompted to continue enter “y” to generate the local keypair file:

[recover] seed phrase: 
[recover] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue: 
Recovered pubkey `abc123`. Continue? (y/n): y
Wrote recovered keypair to /Users/matt/.config/solana/id.json

If all went well you should be able to run a command like solana balance to access the account balance:

$ solana balance

0.123456789 SOL

You can also confirm that the file you generated above maps back to the public key associated with your Phantom wallet:

$ solana-keygen pubkey


Or verify that the public key is correctly associated with your local private key:

$ solana-keygen verify abc123

Verification for public key: abc123: Success

3 thoughts on “Using a Phantom Wallet Address with the Solana CLI

  1. This post is SUPER helpful! I couldn’t find any good documentation for the `’prompt:?key=0/0’` part of the command.

    There’s one thing I’m still stuck on: how do we generate a keypair if our Phantom contains multiple wallets? When I run the exact commands above, they generate a keypair for only the first wallet. But I want to recover a different wallet. I’m confused how this works since there seems to be only one “secret recovery phrase” for them all.

Leave a Reply to Emerson (@emersonthis) Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s