ethereum / web3.py

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

AttributeError: 'Contract' object has no attribute 'eventFilter' #1508

Closed jerryji closed 4 years ago

jerryji commented 4 years ago
alembic==0.9.9
anyconfig==0.9.4
APScheduler==3.5.1
apturl==0.5.2
argh==0.26.2
arrow==0.13.0
asciidoc3==3.1.0.post4
asn1crypto==0.24.0
attrdict==2.0.0
attrs==17.4.0
base58==1.0.3
beautifulsoup4==4.6.0
bitcoin==1.1.42
blinker==1.4
Brlapi==0.6.6
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
chrome-gnome-shell==0.0.0
click==6.7
cloudpickle==0.5.6
coincurve==7.1.0
command-not-found==0.3
contextlib2==0.5.5
cryptography==2.2.2
cupshelpers==1.0
cycler==0.10.0
cytoolz==0.10.1
dask==0.19.2
decorator==4.3.0
defer==1.0.6
distro-info===0.18ubuntu0.18.04.1
docopt==0.6.2
elasticsearch==6.3.1
eth-abi==2.0.0
eth-account==0.4.0
eth-hash==0.2.0
eth-keyfile==0.5.1
eth-keys==0.2.4
eth-rlp==0.1.2
eth-tester==0.1.0b23
eth-testrpc==1.3.3
eth-typing==2.2.0
eth-utils==1.8.0
ethereum==1.6.1
feedparser==5.2.1
flake8==3.5.0
Flask==1.0.2
Flask-APScheduler==1.10.1
Flask-Cors==3.0.8
Flask-DebugToolbar==0.10.1
Flask-Login==0.4.1
Flask-Mail==0.9.1
Flask-SQLAlchemy==2.3.2
Flask-SSE==0.2.1
Flask-Webpack==0.1.0
Flask-WTF==0.14.2
future==0.16.0
geographiclib==1.50
geopy==1.20.0
gevent==1.3.7
greenlet==0.4.15
grip==4.5.2
gunicorn==19.9.0
hexbytes==0.1.0
hiredis==1.0.0
html5lib==0.999999999
htmlmin==0.1.12
httplib2==0.9.2
idna==2.7
importlib-metadata==0.23
iotop==0.6
ipfshttpclient==0.4.12
ipython==5.5.0
ipython-genutils==0.2.0
itsdangerous==0.24
Jinja2==2.10
json-rpc==1.10.8
jsonschema==3.1.1
kazam==1.4.5
keyring==10.6.0
keyrings.alt==3.0
kiwisolver==1.0.1
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
louis==3.5.0
lru-dict==1.1.6
lxml==4.2.1
macaroonbakery==1.1.3
Mako==1.0.7
Markdown==3.1.1
MarkupSafe==1.0
matplotlib==3.1.1
mccabe==0.6.1
meld==3.18.0
meld3==2.0.0
more-itertools==4.1.0
msgpack==0.5.4
multiaddr==0.0.8
mypy-extensions==0.4.3
neovim==0.2.1
netaddr==0.7.19
netifaces==0.10.4
networkx==2.2
nose==1.3.7
numpy==1.17.2
oauth==1.0.1
oauthlib==2.0.6
olefile==0.45.1
opencv-python==3.4.3.18
pandas==0.25.1
parsimonious==0.8.0
path-and-address==2.0.1
pathtools==0.1.2
pbkdf2==1.3
pexpect==4.2.1
pickleshare==0.7.4
Pillow==5.3.0
pluggy==0.6.0
pngquant==1.0.6
populus==2.2.0
prettytable==0.7.2
prompt-toolkit==1.0.15
protobuf==3.10.0
psutil==5.4.2
psycopg2==2.8.3
py==1.5.3
py-ecc==1.4.2
py-geth==2.0.1
py-solc==2.1.0
pycairo==1.16.2
pycodestyle==2.3.1
pycosat==0.6.3
pycparser==2.18
pycrypto==2.6.1
pycryptodome==3.9.3
pycups==1.9.73
pyethash==0.1.27
pyflakes==1.6.0
Pygments==2.2.0
pygobject==3.26.1
PyJWT==1.5.3
pylru==1.0.9
pymacaroons==0.13.0
PyNaCl==1.1.2
PyOpenGL==3.1.0
pyOpenSSL==17.5.0
pyparsing==2.2.1
pyRFC3339==1.0
pyrsistent==0.15.5
pysha3==1.0.2
pytest==3.5.0
python-apt==1.6.4
python-dateutil==2.7.1
python-debian==0.1.32
python-editor==1.0.3
python-xapp==1.0.0
python-xlib==0.20
pytz==2019.2
PyWavelets==1.0.0
pyxattr==0.6.0
pyxdg==0.25
PyYAML==3.12
pyzmq==17.1.2
redis==2.10.6
reportlab==3.4.0
repoze.lru==0.7
requests==2.19.1
requests-unixsocket==0.1.5
rlp==1.0.1
rq==0.12.0
rq-dashboard==0.3.12
scikit-image==0.14.0
scipy==1.1.0
screen-resolution-extra==0.0.0
scrypt==0.8.6
secp256k1==0.13.2
SecretStorage==2.3.1
semantic-version==2.6.0
setproctitle==1.1.10
simplegeneric==0.8.1
simplejson==3.13.2
six==1.11.0
slither-analyzer==0.4.0
SQLAlchemy==1.2.7
ssh-import-id==5.7
supervisor==4.0.4
system-service==0.3
systemd-python==234
toolz==0.9.0
toposort==1.5
traitlets==4.3.2
tzlocal==1.5.1
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
unity-scope-calculator==0.1
unity-scope-chromiumbookmarks==0.1
unity-scope-colourlovers==0.1
unity-scope-devhelp==0.1
unity-scope-firefoxbookmarks==0.1
unity-scope-manpages==0.1
unity-scope-openclipart==0.1
unity-scope-texdoc==0.1
unity-scope-tomboy==0.1
unity-scope-virtualbox==0.1
unity-scope-yelp==0.1
unity-scope-zotero==0.1
unity-tweak-tool==0.0.7
urllib3==1.23
usb-creator==0.3.3
uWSGI==2.0.17
validate-email==1.3
varint==1.0.2
vidcutter==6.0.0
virtualenv==15.1.0
wadllib==1.3.2
watchdog==0.8.3
wcwidth==0.1.7
web3==5.3.0
webencodings==0.5
websockets==8.1
Werkzeug==0.14.1
WTForms==2.1
xkit==0.0.0
youtube-dl==2018.3.14
zipp==0.6.0
zope.interface==4.3.2

What was wrong?

AttributeError: 'Contract' object has no attribute 'eventFilter'

when I run my_contract.eventFilter('TokenTransfer', {'filter': {'fromBlock': 0}}) following the example in web3py latest doc https://web3py.readthedocs.io/en/latest/contracts.html#event-log-object

(Pdb) my_contract
<web3._utils.datatypes.Contract object at 0x7f5ac8027a90>

(Pdb) dir(my_contract)
['__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', 
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', 
'__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', 
'__str__', '__subclasshook__', '__weakref__', '_encode_constructor_data', 
'_find_matching_event_abi', 
'_find_matching_fn_abi', '_prepare_transaction', '_return_data_normalizers', 'abi',
'address', 'all_functions', 'asm', 'ast', 'bytecode', 'bytecode_runtime', 'caller', 
'clone_bin', 'constructor', 'decode_function_input', 'dev_doc', 'encodeABI', 
'events', 'factory', 'fallback', 'find_functions_by_args', 'find_functions_by_name',
'functions', 'get_fallback_function', 'get_function_by_args', 'get_function_by_name', 
'get_function_by_selector', 'get_function_by_signature', 'interface', 'metadata',
'opcodes', 'src_map', 'src_map_runtime', 'user_doc', 'web3']

How can it be fixed?

Please update doc with the correct example. BTW, createFilter works fine with ganache-cli, but unfortunately is not supported by Infura websocket

kclowes commented 4 years ago

Thanks for pointing this out @jerryji! In v5 we removed my_contract.eventFilter for my_contract.events.<event_name>.createFilter(). I can't link directly the the createFilter docs (which is another issue to address), but if you scroll down in this section you'll find the documentation, although it sounds like you've already seen it. I will update the example soon!

BTW, createFilter works fine with ganache-cli, but unfortunately is not supported by Infura websocket

I think createFilter should work with infura websockets... What error are you seeing?

jerryji commented 4 years ago

I think createFilter should work with infura websockets... What error are you seeing?

As I tried to reproduce the issue today, all I got was --

ValueError: {'code': -32601, 'message': 'The method eth_newFilter does not exist/is not available'}

with Infura's https:// endpoint.

As of now createFilter works fine with Infura's wss:// endpoint -- it could well be that I messed up with their websocket url on Sunday.

Thank you @kclowes for looking into this case. I look forward to seeing the updated doc.