Is there a quick and easy way to see the public key of the account that is being used by solana cli?

For example, I know it's possible to cat the file ~/.config/solana/cli/config.yml and cat and see

json_rpc_url: "https://api.mainnet-beta.solana.com"
websocket_url: ""
keypair_path: /root/.config/solana/id.json
  "11111111111111111111111111111111": System Program
commitment: confirmed

but does the cli have a way of showing what is the public key of id.json (or whatever keypair you happen to have in the config file)?


3 Answers 3


This is easily done with solana address. You can always change the id the CLI is using with solana config set -k <path_to_another_json>

  • yeh, it is super simple. Figured it out just after asking by just running solana -help and seeing what commands were available
    – Henry E
    Commented Oct 13, 2022 at 15:00

You can also go to your json file directly: /root/.config/solana/id.json and import via a private key in Phantom everything you have in the json file. This will allow you to have the wallet on Phantom and to be able to make transactions, see the activities etc.. more easily

  • uploading the private key to phantom just to get the public key isn't really quick and/or easy though, and it doesn't use the CLI. But for sure, I've definitely done this in the past
    – Henry E
    Commented Oct 13, 2022 at 19:20

And yet one more option using a lighter command, you can just do solana-keygen pubkey

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.