satisfywithmylife
phantom-py
Python

python for blockchain wallet phantom, suport use mnemonic seeds generate solana, ethereum address and private key

Last updated May 16, 2026
36
Stars
6
Forks
0
Issues
0
Stars/day
Attention Score
18
Language breakdown
Python 100.0%
Files click to expand
README

phantom-py

python for blockchain wallet phantom, suport use mnemonic seeds generate solana, ethereum address and private key

pip

pip install bip_utils==2.7.0

code

from bip_utils import Bip39SeedGenerator, Bip44Coins, Bip44, base58, Bip44Changes

class BlockChainAccount():

def init(self, mnemonic, coin_type=Bip44Coins.ETHEREUM, password='') -> None:

self.mnemonic = mnemonic.strip() self.cointype = cointype self.password = password # if have password

def getaddresspk(self):

seed_bytes = Bip39SeedGenerator(self.mnemonic).Generate(self.password) if self.coin_type != Bip44Coins.SOLANA: bip44mstctx = Bip44.FromSeed(seedbytes, self.cointype).DeriveDefaultPath() return bip44mstctx.PublicKey().ToAddress(), bip44mstctx.PrivateKey().Raw().ToHex() else: bip44mstctx = Bip44.FromSeed(seedbytes, self.cointype) bip44accctx = bip44mstctx.Purpose().Coin().Account(0) bip44chgctx = bip44accctx.Change(Bip44Changes.CHAIN_EXT) # if you use "Solflare", remove this line and make a simple code modify and test privkeybytes = bip44chgctx.PrivateKey().Raw().ToBytes() publickeybytes = bip44chgctx.PublicKey().RawCompressed().ToBytes()[1:] keypair = privkeybytes+publickey_bytes

return bip44chgctx.PublicKey().ToAddress(), base58.Base58Encoder.Encode(key_pair)

test

mnemonic = 'oblige receive elite random advance payment wife detect tomorrow source borrow mixture'
print(f'mnemonic: {mnemonic}')
coin_types = {
    Bip44Coins.ETHEREUM: 'ethereum(evm)',
    Bip44Coins.SOLANA: 'solana',
    # Bip44Coins.TERRA: 'luna',
    # Bip44Coins.DASH: 'dash',
    # .....
    # also support other chain, such as file coin, eth classic, doge, dash, luna ....
    # example change coin_type as Bip44Coins.EOS, Bip44Coins.TERRA .....
   
}
for cointype in cointypes.keys():
    chainname = cointypes[coin_type]
    bca = BlockChainAccount(mnemonic=mnemonic, cointype=cointype)
    address, pk = bca.getaddresspk()
    print(f'{chain_name} mainnet address: {address}, private key: {pk}')

result

mnemonic: oblige receive elite random advance payment wife detect tomorrow source borrow mixture
ethereum(evm) mainnet address: 0x58eE4fd2e1D2c970E1fAA8f888CFd1cA27BD4A28, private key: 4a68dfa8cb029fb5490cb36bb9c4c6523bada89134e40d2498cf83d7b4295cfb
solana mainnet address: 6RVympP2ZLR3T3KTSiqzCcBTvjRhT4UDCCt8AsbkYg2b, private key: 58hvcp5Lje9us9Q1QJdWV8aATcJKeHNZudyN9jWuiNYtRGFhJrH97Qe4ew8VmxLx5VCEYEuHGWRZuaFLr6A4euqR

import the mnemonic seed to phantom wallet , get result

phantom

init account with python

pip install solana, web3

test solana, eth

from solders.keypair import Keypair
from web3 import Web3

solana

solanaprivatekey = '58hvcp5Lje9us9Q1QJdWV8aATcJKeHNZudyN9jWuiNYtRGFhJrH97Qe4ew8VmxLx5VCEYEuHGWRZuaFLr6A4euqR' kp = Keypair().frombase58string(solanaprivatekey) # private key print(kp.pubkey()) # get "6RVympP2ZLR3T3KTSiqzCcBTvjRhT4UDCCt8AsbkYg2b", solana address

eth

w3 = Web3(Web3.HTTPProvider("https://cloudflare-eth.com/v1/mainnet")) ethprivatekey = '4a68dfa8cb029fb5490cb36bb9c4c6523bada89134e40d2498cf83d7b4295cfb' ac = w3.eth.account.fromkey(ethprivatekey) # privatekey print(ac.address) # get "0x58eE4fd2e1D2c970E1fAA8f888CFd1cA27BD4A28", eth address

last but important!

  • test the result and compare it with main web wallet app(such as: metamask, mathwallet, trustwallet...) before you deposit crypto assets to the address
  • some wallet may get diffrent result, because it may use diffrent derive path to generate wallet
  • learn about hd-wallet principle by your self

© 2026 GitRepoTrend · satisfywithmylife/phantom-py · Updated daily from GitHub