1

How do I recover address wallet by use private-key? Following solana doc, it just showing recover address by seed phrase, and I want to recover by private-key

1 Answer 1

3

Code Snippet

Step 1: import lib:

import { bs58 } from "@project-serum/anchor/dist/cjs/utils/bytes";
import { web3 } from "@project-serum/anchor";

Step 2: Call function:

const getKeypair = await web3.Keypair.fromSecretKey(bs58.decode("private-key"));
console.log(`public key: ${getKeypair.publicKey}`);

Also, you can just simply import the private key in your Phantom Wallet and you are good to go. You will see your public address and digital assets right away.

enter image description here

2
  • oh, I want to recover by code as nodejs
    – soler
    Jan 10 at 10:51
  • ops let me edit my answer then Jan 10 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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