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

abc123

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

$ solana-keygen verify abc123

Verification for public key: abc123: Success