I want is to listen to the event "IPFSHash" defined in a Solidity contract in a python module using web3.py (with blockchain created by ganache-cli, transactions triggered through Remix IDE also connected through Web3 Provider). I tried using this construct:

event_filter = my_contract.events.IpfsHash.createFilter(fromBlock='latest')

However, I don't get any new entries in the filter when triggering the event through Remix. I can however call the getHash function to confirm that the value of "hash" is changed in the contract and the event has been emitted (full code below).


Web3.py code:

import json
from web3.providers.rpc import HTTPProvider
from web3 import Web3
import time

w3 = Web3(HTTPProvider('http://localhost:8545'))
contract_address = 

with open('contract_abi.json', 'r', encoding='utf-8') as abi_file:
    contract_abi = json.loads(abi_file.read())

my_contract = w3.eth.contract(address=contract_address, abi=contract_abi)

event_filter = my_contract.events.IpfsHash.createFilter(fromBlock='latest')

poll_interval = 2

def handle_event(event):
    print("Event triggered")

while True:
   print("New entries: ", len(event_filter.get_new_entries()))
   for event in event_filter.get_new_entries():
   print("Get Hash:", contract.functions.getHash().call())

Solidity contract code:

pragma solidity ^0.4.21;
contract HashEventTest{
    bytes public hash;

    event IpfsHash(
        bytes ipfs_hash,
        address sender

    function HashEventTest(bytes _hash) public {
        hash = _hash;

    function setHash(bytes _hash) public {
        hash = _hash;
        emit IpfsHash(hash, msg.sender);

    function getHash() public constant returns (bytes){
        return hash;

1 Answer 1


had the same issue and reproted it. See here the discussion. No solution yet.

However, the old method works fine, for instance:

myfilter = mycontract.eventFilter('EventName', {'fromBlock': 0,'toBlock': 'latest'});
eventlist = myfilter.get_all_entries()

This will work.

hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.