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
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.