web3.py: No matching events found

  • Version: v4.2.0
  • Python: 3.5
  • OS: linux
  • Geth: 1.8.6-stable, private network (with rpcapi=“db,eth,net,web3,personal,web3”)

Script

import json, web3, time
from web3 import Web3, HTTPProvider

def setup_Web3():
    global web3
    web3 = Web3(HTTPProvider('http://localhost:8545'))

def make_request(contract_interface, contract_address):
    deployed_Contract = web3.eth.contract(abi=contract_interface['abi'], address=contract_address)
    last_block_num = w3.eth.getBlock('latest').number
    event_filter = deployed_Contract.events.PermissionRequestDeployed.createFilter(fromBlock=last_block_num)
    transfer_filter = deployed_Contract.eventFilter('PermissionRequestDeployed')
    while True:
        print ("Event_filter: {}".format(event_filter.get_new_entries()))
        print ("Transfer_filter: {}".format(transfer_filter.get_new_entries()))
        time.sleep(0.1)
        print("listening...")

def handle_event(event):
    print(event)

setup_Web3()
#loading resources
make_request(contract_interface,  contract_address)`

Output

Event_filter: []
Transfer_filter: [AttributeDict({'logIndex': 0, 'transactionIndex': 0, 'blockNumber': 1262, 'blockHash': HexBytes('0x82383db66f6ac078180a1687dd54365e140c45fba85b893d374efa360c234aec'), 'address': '0x0aF62bE1f6c6a9F1c569c362eAdcDA9198eb9688', 'transactionHash': HexBytes('0x82d8591df9951bb9759a55b53fc6db26c89f9bf07373758c197217d2cdd6f60c'), 'event': 'PermissionRequestDeployed', 'args': AttributeDict({'permissionId': b'o\x80Zb\xf1\x07t\xdf\xf4\x1e\xe1\x11\x86\xbcF\x8bt=\xf9\x86\xf9\xee,\xb4\xe0\xc0\x1eL\xa4\xbe[\xef'})})]

last_block_num was set to Block 1895. The transaction was mined in Block 1897.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (16 by maintainers)

Most upvoted comments

Since the same behavior is happening with a numbered block as with “latest”, Im lead to believe this to be something else weird between the two api’s. The two implementations do have some differences in the resulting filter parameters they generate. The new createFilter api will be more strict in matching events, whereas the eventFilter will be less strict.

@Lebski Can you paste the values of the following attributes?

event_filter.filter_params
transfer_filter.filter_params

Ok, I’m going to reopen this, and update the summary with this info. It seems like a Web3.py bug, if not in the code, then in the docs.

Oh damn, sorry. I chagend the code to be minimalistic for the Issue but copied the wrong console output. It was PermissionRequestdeployed in the Smart-Contract and I copy + pasted it in the python file. Assert the Variable-Names as correct. Checked them in the original files at least a 1000 times. 'Sorry again.

Edit: I know it should say, but i was sort of a proof of concept