4

I am very new to blockchain programming and programming in general. I want to generate my SOL address using the mnemonic seed phrase with the derivation path "m/44'/501'/0'/0". I can't find a proper BIP44 module for python where you can specify the derivation path.

Tyaaz
  • 71
  • 1
  • 6

1 Answers1

2

After a long search through the internet, I have finally found a way of solving my problem that I want to share with you.

from bip_utils import *

MNEMONIC = "...12 words phrase..."

seed_bytes = Bip39SeedGenerator(MNEMONIC).Generate("")

bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.SOLANA)

bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)

bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)

print(bip44_chg_ctx.PublicKey().ToAddress())

This code outputs the first address of your mnemonic. This is only for Sollet and Phantom wallet!

If you are using Solflare you can cut the line bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT) out!

Tyaaz
  • 71
  • 1
  • 6
  • i tryed your script with an example seed from bip39 wordslist : MNEMONIC = "again viable dwarf radio sad crisp anxiety conduct sure have girl net" i got : bip_utils.utils.mnemonic.mnemonic_ex.MnemonicChecksumError: Invalid checksum (expected 0101, got 1001) Any idea ? THanks – VeilleurTryToFix Aug 27 '22 at 12:06