0

If I import a seed phrase with @solana/web3.js I seem to get different public address than the ones generated by Phantom wallet when I import the same seed phrase. Anyone any idea why?

const seed = Bip39.mnemonicToSeedSync("<12 word phrase>").slice(0, 32);

const mint_authority = web3.Keypair.fromSeed(seed)

do I need to do anything with derivation paths so that addresses generated match those of Phantom wallet ?

1977
  • 2,580
  • 6
  • 26
  • 37

1 Answers1

0

You can use this code. It runs correctly in my side.

seed_bytes = Bip39SeedGenerator(cfg.ETH_TEMP_MNEMONIC).Generate()
  bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)
  for i in range(100):
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(i)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)

    new_wallet = WalletData()
    new_wallet.public_key = bip44_chg_ctx.PublicKey().ToAddress()
    new_wallet.private_key = Base58Encoder.Encode(
        bip44_chg_ctx.PrivateKey().Raw().ToBytes() + bip44_chg_ctx.PublicKey().RawCompressed().ToBytes()[1:]
    )
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 20 '22 at 14:20