# generate_wallet.py from eth_account import Account def generate_evm_wallet(num_words: int = 12, passphrase: str = ""): # HD 钱包能力需要显式开启(官方注明:实验性/未审计,未来可能变更) Account.enable_unaudited_hdwallet_features() acct, mnemonic = Account.create_with_mnemonic( passphrase=passphrase, num_words=num_words, # 12/15/18/21/24 account_path="m/44'/60'/0'/0/0", # EVM 常用路径 ) return mnemonic, acct.address, acct.key.hex() if __name__ == "__main__": mnemonic, address, privkey = generate_evm_wallet(num_words=12) print("mnemonic :", mnemonic) print("address :", address) print("privkey :", privkey)