如何使用助记词创建Web3py帐户

ElA*_*725 4 python python-3.x web3py

我正在使用 web3 制作自己的桌面 BSC 钱包。目前我正在使用

private_key = "private key"
account = w3.eth.account.privateKeyToAccount(private_key)
Run Code Online (Sandbox Code Playgroud)

但我想使用助记词短语(如“你好约翰披萨吉他”)创建帐户。我一直在寻找,但无法实现。

Rut*_*rus 7

目前请求的功能在 Web3.py 中不稳定

  • 选项 1:使用一些库(例如以太坊助记符 Utils)来处理您的种子。
  • 选项 2:在 web3py 中启用未经审核的功能
web3 = Web3()
web3.eth.account.enable_unaudited_hdwallet_features()
account = web3.eth.account.from_mnemonic(my_mnemonic, account_path="m/44'/60'/0'/0/0")

Run Code Online (Sandbox Code Playgroud)

注意:默认也account_path匹配以太坊和 BSC。迭代最后一个数字,您将获得下一个帐户。账户对象可以管理一些操作

web3 = Web3()
web3.eth.account.enable_unaudited_hdwallet_features()
account = web3.eth.account.from_mnemonic(my_mnemonic, account_path="m/44'/60'/0'/0/0")

Run Code Online (Sandbox Code Playgroud)