Created
February 14, 2024 22:16
-
-
Save Lohann/a56c7a070c84e573e0dc7f144dc8f928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
-- requirements.txt | |
bip_utils==2.9.1 | |
mnemonic==0.21 | |
""" | |
from mnemonic import Mnemonic | |
from bip_utils import Bip44, Bip44Changes, Bip44Coins | |
mnemonic = "bottom drive obey lake curtain smoke basket hold race lonely fit walk" | |
passphrase = "password here" | |
# Load seed from mnemonic | |
seed_bytes = Mnemonic("english").to_seed(mnemonic, passphrase=passphrase) | |
print(f" bip32 seed: {seed_bytes.hex()}") | |
# Construct from seed | |
hd_wallet = Bip44.FromSeed(seed_bytes, Bip44Coins.ETHEREUM) | |
# Derive BIP44 account keys: m/44'/60'/0'/0/0' | |
account = hd_wallet.Purpose().Coin().Account(0).Change(Bip44Changes.CHAIN_EXT).AddressIndex(0) | |
print(f"Private Key: 0x{account.PrivateKey().Raw().ToHex()}") | |
print(f" Address: {account.PublicKey().ToAddress()}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment