Skip to content

HTTPError at /testing/ 405 Client Error: Method Not Allowed for url: #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rabiaasif opened this issue Aug 30, 2018 · 2 comments
Closed

Comments

@rabiaasif
Copy link

  • Version: x.x.x
  • Python: 2.7/3.4/3.5
  • OS: osx/linux/win

What was wrong? --- Can't call create filter on contract

Please include any of the following that are applicable:

  • The code which produced the error
    myContract = w3.eth.contract(address="some_address",abi=contract_abi) #this works fine, i can call methods from here and i get a response

    myfilter_new= myContract.events.Transfer.createFilter(fromBlock=0, toBlock='latest')
    #when i run this, i get the following issue:

  • The full output of the error:

HTTPError at /testing/
405 Client Error: Method Not Allowed for url: https://rinkeby.infura.io/my_api_key

Fill this section in if you know how this could or should be fixed.

@dylanjw
Copy link
Contributor

dylanjw commented Aug 30, 2018

Infura does not support the eth_newFilter rpc endpoint, because it requires creating stateful filter on the node, and in general Infura doesnt support stateful api's. Infura does support the non-stateful endpoint eth_getLogs. There is an open pull request for a middleware that creates a locally managed filter that uses eth_getLogs (#732). Until that is released, you have the option of using web3.eth.getLogs() or running a local node, like parity or go-ethereum.

An example of using getLogs(), with the assumption that the event is not anonymous:

from eth_utils.abi import event_abi_to_log_topic

event_signature_topic = event_abi_to_log_topic(myContract.events.Transfer.abi)
found_logs = w3.eth.getLogs(
    {
        'address':myContract.address, 
        'fromBlock':0, 
        'toBlock':'latest', 
        'topics':[event_signature_topic]
    })

@carver
Copy link
Collaborator

carver commented Sep 3, 2018

I understand from other threads that you can now use filters with the websocket provider on Infura.

Anyway, this isn't a web3.py bug, so I'll close. Feel free to continue commenting for support, though.

@carver carver closed this as completed Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants