I see wallets like phantom and solflare pop up with a list of accounts when you import a seed phrase. How does that work? How can you find all of those through code? Can you generate new ones? Also if I just generated a new keypair. How could I use that seed as the base for the rest of the wallets I make?

1 Answer 1


This is due to hierarchical derivation, which essentially defines many different ways of generating a private key from a seed phrase.

For example, given a seed phrase like immense soup feed arrest erupt arrow little nephew regular trap radio danger, which solana-keygen gives a pubkey of jtFuWc4r1Y6UNuU13LngguXuyozapVnRVfnv9VwqWKr, you can do:

solana-keygen pubkey prompt://?key=0/1
<Paste the words here>


solana-keygen pubkey prompt://?full-path=m/44/2017/0/1
<Paste the words here>

Depending on your derivation path, you'll different private keys.

More information in the Solana docs at https://docs.solana.com/wallet-guide/paper-wallet#hierarchical-derivation

To do this in code, you can use the ed25519_dalek_bip32 crate, and do something like:

let seed = "blouse clerk fault regular grocery chat figure squeeze question catalog athlete predict";
let derivation_path = "44'/501'";
let extended = ed25519_dalek_bip32::ExtendedSecretKey::from_seed(seed)
        .and_then(|extended| extended.derive(&derivation_path))?;
let extended_public_key = extended.public_key();
ed25519_dalek::Keypair {
    secret: extended.secret_key,
    public: extended_public_key,

You can find the whole source code for solana-keygen at You can see all of the solana-keygen code at https://github.com/solana-labs/solana/blob/master/keygen/src/keygen.rs

  • How can I do this from code? And not CLI
    – Pixeled
    Commented Sep 18, 2022 at 20:10
  • Updated with a code example
    – Jon C
    Commented Sep 19, 2022 at 20:46
  • Do you have code for python I can use?
    – Pixeled
    Commented Oct 1, 2022 at 20:30

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.