How to share your wallet in Solana between Phantom and the cli
Introduction
One of the first step when you develop on a blockchain is to create one of multiple public keys that you can use to test your program.
To do that, you need to create a wallet that will hold your public keys.
Phantom is a very popular Wallet solution - as the website says, Phantom is a browser extension that makes it easy to store, buy, send, receive, swap tokens and collect NFTs on the Solana blockchain.
When you are developing a program on Solana, you prefer to use the different cli tools to interact with the blockchain.
This article will describe how you can share your public keys between Phantom and the cli.
Phantom installation
There are a lot of documents that describe how to install the phantom extension and you should follow this instructions described here: https://phantom.app/download
When installing the extension, you will be presented first with that screen:
Unless you already had a wallet with Phantom, you must click on “Create a new wallet”
This will then ask you to create a password: this password will protect the access to your Phantom extension from your browser.
The final step will give you access to your “secret recovery phrase” :
Important: It is very important that you keep both your Phantom password and the secret recovery phrase secret. If you leak them, an attacker could steal all your tokens from all your Solana addresses…
Solana CLI wallet creation
You need first to install the different Solana CLI tools:
There is an option to recover your keys from the seed phrase using:
If you use the seed phrase that you got from Phantom, the recovered pubkey won’t be the key that you have in Phantom.
The issue seems to be that the seed phrases management between Phantom and the Solana CLI are not compatible.
You can still share public keys between those 2 environments.
The solution is to create a new key using the Solana cli:
You get here a new seed phrase that you should also store securely.
At this stage you now have 2 Solana addresses : one in Phantom and one in the CLI.
As Phantom provides a nice and convenient interface to interact with your key, you want to import your cli key inside Phantom.
For your development needs, you may want to get SOLs from the dev network:
Import your CLI Solana key to Phantom
Note: the steps to do that were found in reddit.
The private key for your cli address is stored in plain text in the file : ~/.config/solana/id.json
The first step is copy it:
Then, using the hamburger menu in the Phantom extension, click on “Add / Connect Wallet”
Then “Import private key” :
In that screen, you can give a name and paste the private key of your cli address:
If you switch to the dev network in Phantom, you’ll then be able to see the SOLs you air dropped perviously: