0

What is the difference between the web3 filter methods and the subscribe ones?:

Filter methods:

enter image description here

Subscribe methods:

enter image description here

I cannot see to understand the difference. And which one you would recommend in each situation.

In my personal case, i need to read ERC1155 'TransferSingle' and 'TransferBatch' events from a particular shared contract in opensea.

Many thanks

1 Answer 1

1

In particular, eth_subscribe will only get new events. There is no built-in way to say "Starting with historical block N, get me all logs matching the filter criteria (e.g. TransferSingle events) for a contract address X and then wait and keep watching for new logs to appear." You have to craft this logic yourself, including protecting against race conditions.

Also: note that web3.js supports

web3.eth.subscribe(type [, options] [, callback]);

but web3.py does not support the subscribe method (v6.1.0, as of 4-Jun-2023)

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.