'how to generate keypair from secret phrase (mnemonic) SOLANA

hello guys i am working with solana and phantom wallet i have a wallet with a public key and i have it's secret phrase composed of 12 word. when i generate keypairs from the secret phrase i use :

const getKeyPair = (mnemomic) => {
  const seed = bip39.mnemonicToSeedSync(mnemomic).slice(0, 32);
  const Keypair = web3.Keypair.fromSeed(seed);
  return Keypair;
};

the generated keypair has publicKey and privateKey , but when am checking my balance using the generated public key i find it always 0 even when i try to airdrop sols using my code it's not getting in the account. but if i check using my public key from phantom wallet i get the sols i have and if i want to airdrop sols they also proceed normally. please help i need to know what is happening why generated public key is not the same as the one in phantom wallet.



Solution 1:[1]

solana-keygen recover 'prompt:?key=0/0' -o phantom_wallet.json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank C.