Here's what I've done so far.

import json
import sys

import web3
from web3 import Web3, IPCProvider

ADDRESS = '...' #contract address
PIPE = '\\\\.\\pipe\\geth.ipc'

w3 = Web3(IPCProvider(PIPE))
f = w3.eth.filter({
    'contract_address': ADDRESS,
    'toBlock': "latest"
def callback(block_hash):
    sys.stdout.write("New Block: {0}".format(block_hash))

however this doesn't seem to monitor just the contract I specify with contract_address it seems to monitor all (as if I had done f = w3.eth.filter('latest'))

  • Where did you see contract_address documented?
    – user19510
    Mar 22, 2018 at 5:46
  • I assumed I could use the same arguments that construct_event_filter_params uses. I couldn't find what arguments I could be using for LogFilter.
    – John
    Mar 22, 2018 at 5:49

2 Answers 2


The fields that you can use for setting up a filter are defined in the JSON-RPC docs for eth_newFilter.

Specifically, the address field is just address:

address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.

So the filter should be set up with:

f = w3.eth.filter({
    'address': ADDRESS,
    'toBlock': "latest"
  • 1
    This will work only if the contract has logged one event, and will not be called if no event was logged or if the transaction was reversed.
    – Ismael
    Mar 22, 2018 at 16:30

Use address instead of contract_address. I've just checked the documentation at http://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.filter, but didn't test it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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