0

i used generated keypair output to file so there are only bytes that are saved and got my public key but i still can't got my private key. Any help or hint how can i solve this ?

2 Answers 2

2

If you have the output json file you have the entire public and private key. If you want the mnemonic and you didn't save it you'll have to generate a new keypair. This is irreversible by design.

The first 32 values in the YOUR_KEYPAIR.json is the private key.

If you have Sol in the wallet, generate a new keypair, write down the mnemonic and then transfer the Sol from the old address to the new one.

12
  • Thank you for your answer but is it possible to use that private key to import it into Phantom wallet please? Commented Dec 21, 2023 at 9:09
  • so there is no way i can import it to a browser wallet ? there isn't a way that would allow me to convert those byte private key into seed ? Commented Dec 21, 2023 at 11:00
  • I am not sure on the import. It’s certainly possible to do in theory. Commented Dec 21, 2023 at 11:01
  • What do you mean convert private key into a seed? You may be able to copy/paste the key into the wallet but I’m not sure. Commented Dec 21, 2023 at 11:02
  • i means, the browser wallet accept hex private key while the json is byte format (maybe it accept byte format but i'm not sure) Commented Dec 21, 2023 at 11:13
0

thanks to David Lampach who explained me that i need to encode the bytes to base58 to have access to my wallet. Ty lot sir, i don't know at all how solana works

In future if someone would have same problem as me

first import bs58 crate to your cargo project

then use this code to get your private key seed to connect browser wallet

fn main() {
    let vector_of_your_64_bytes = vec![];
    let data = bs58::encode(vector_of_your_64_bytes);

    println!("{:?}", data.into_string());
}

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.