ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
5.01k stars 1.71k forks source link

AttributeError: 'AsyncEth' object has no attribute 'account' #2683

Closed mazepas closed 2 years ago

mazepas commented 2 years ago
aiofiles==22.1.0
aiohttp==3.8.1
aiosignal==1.2.0
anyio==3.6.1
appdirs==1.4.4
APScheduler==3.6.3
async-generator==1.10
async-timeout==4.0.2
attrs==21.4.0
base58==2.1.1
bech32==1.2.0
betterproto==2.0.0b4
bip32utils==0.3.post4
bitarray==2.5.1
boltons==21.0.0
cachetools==4.2.2
capmonster-python==2.2
cattrs==1.10.0
certifi==2021.10.8
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.12
click==8.1.3
click-completion==0.5.2
click-default-group==1.2.2
colorama==0.4.4
commonmark==0.9.1
cosmospy==6.0.0
cryptography==37.0.2
cucumber-tag-expressions==4.1.0
cytoolz==0.11.2
decorator==5.1.1
ecdsa==0.17.0
eth-abi==2.2.0
eth-account==0.5.9
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.4
eth-rlp==0.2.1
eth-typing==2.3.0
eth-utils==1.10.0
etherscan==0.3.0
fake-useragent==0.1.11
frozenlist==1.3.0
furl==2.1.3
grpclib==0.4.2
h11==0.12.0
h2==4.1.0
hdwallet==2.1.1
hdwallets==0.1.2
hexbytes==0.2.2
hpack==4.0.0
httpcore==0.14.7
httpx==0.22.0
hyperframe==6.0.1
idna==3.3
imbox==0.9.8
ipfshttpclient==0.8.0a2
Jinja2==3.1.2
jsonpath-ng==1.5.3
jsonschema==4.6.0
loguru==0.6.0
lru-dict==1.1.7
lxml==4.9.0
MarkupSafe==2.1.1
mnemonic==0.19
multiaddr==0.0.9
multidict==6.0.2
nest-asyncio==1.5.5
netaddr==0.8.0
orderedmultidict==1.0.1
outcome==1.2.0
parsimonious==0.8.1
pluggy==1.0.0
ply==3.11
pprintpp==0.4.0
protobuf==3.20.1
pycparser==2.21
pycryptodome==3.14.1
Pygments==2.12.0
pyOpenSSL==22.0.0
pyrsistent==0.18.1
pysha3==1.0.2
PySocks==1.7.1
python-dateutil==2.8.2
python-dotenv==0.21.0
python-telegram-bot==13.12
pytz==2022.1
pytz-deprecation-shim==0.1.0.post0
pywin32==304
requests==2.27.1
requests-cache==0.9.4
rfc3986==1.5.0
rich==12.4.4
rlp==2.0.1
selenium==4.3.0
shellingham==1.4.0
six==1.16.0
sniffio==1.2.0
sortedcontainers==2.4.0
telegram-send==0.34
terra-proto==1.0.1
terra-sdk==2.0.6
tomli==2.0.1
toolz==0.11.2
tornado==6.1
trio==0.21.0
trio-websocket==0.9.2
tzdata==2022.1
tzlocal==4.2
url-normalize==1.4.3
urllib3==1.26.9
utils-eth==2.0.5
varint==1.0.2
ward==0.66.0b0
web3==5.29.2
web3-eth==6.0.0b6
websockets==9.1
win32-setctime==1.1.0
wrapt==1.14.1
wsproto==1.1.0
yarl==1.7.2

What was wrong?

import asyncio
import aiofiles
from hexbytes import HexBytes
from mnemonic import Mnemonic
from datetime import datetime, timedelta
from string import ascii_letters
#from web3 import Web3
from web3.eth import AsyncEth

rpc = 'https://mainnet.ethereumpow.org'
web3 = Web3(Web3.AsyncHTTPProvider(rpc), modules={'eth': (AsyncEth,)})
#web3 = Web3(Web3.HTTPProvider(rpc)
w3 = Web3()
w3.eth.account.enable_unaudited_hdwallet_features()
...
private_key = web3.eth.account.from_mnemonic(seed, account_path="m/44'/60'/0'/0/0")
private_key_string = str(HexBytes(private_key.privateKey).hex())
new_account_eth_address = private_key.address
...

**Traceback (most recent call last):**
...
  File "C:\Users\HOME\Documents\Python\test.py", line 40, in tx
    private_key = web3.eth.account.from_mnemonic(seed, account_path="m/44'/60'/0'/0/0")
                │      │                                             └ '* * *'
                │      └ <web3.eth.AsyncEth object at 0x000001F6C80A1600>
                └ <web3.main.Web3 object at 0x000001F6C45776D0>

AttributeError: 'AsyncEth' object has no attribute 'account'

Without async web3 work fine but I need async for my project

fselmo commented 2 years ago

Hey @mazepas. ~This is available in web3.py v6 which is in beta at the moment. I honestly don't see a reason why we can't back-port this functionality to v5 as a feature as well so I can put up a PR for that. But for now, if you'd like to use account as part of AsyncEth,~ you can try out the latest v6 beta from this list.


edit: It's actually available in the latest v5 versions already. I'd just recommend a pip install --upgrade web3. That should do the trick. But if you want to have more async functionality, I would definitely encourage you try out the latest v6 beta version! Best of luck.