web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.18k stars 4.91k forks source link

web3.eth.filter not exist #983

Closed facelinker closed 4 years ago

facelinker commented 7 years ago

When i call web3.eth.filter() compiler throw error "TypeError: web3.eth.filter is not a function".

frozeman commented 7 years ago

In 1.0 you use web3.eth.subscribe. But this will only work on websocket. And IPC connections.

If there is a case for we adding the old filter, we can discuss it here

morelazers commented 7 years ago

Docs don't mention subscribe here: https://github.com/ethereum/wiki/wiki/JavaScript-API

Is it still safe to use filter on an older version of web3.js? What's the reason it's being deprecated?

cmditch commented 7 years ago

web3 version 0.20 is web3.eth.filter, version 1.0 (in beta) is web3.eth.subscribe. You'll want to check your web3 version.

As @frozeman said, subscribe will not work with an HTTP Provider, only websocket and IPC. Web3 1.0 uses pub/sub listening for logs/events, while web3 0.20 used polling.

doronaviguy commented 7 years ago

Correct docs link here

szerintedmi commented 6 years ago

So what is our option with web3@1.0 when we want to listen to events using http provider?

chiro-hiro commented 6 years ago

@szerintedmi @frozeman Might be we need to implement HTTP/2. It will be awesome to use subscribe with HTTP provider.

https://tools.ietf.org/html/rfc7540#section-8.2

szerintedmi commented 6 years ago

any solution would be great. Our workaround is ethers.js just for subscribe and getLogs which works like a charm. But not really happy pulling in a whole, overlapping functionality lib just for that.

jamesmorgan commented 5 years ago

Does the subscription function support start and end block like the filter method?

nivida commented 5 years ago

@jamesmorgan Yes, it does. Hopefully, we can soon implement the Http 2.0 subscriptions.

coderNeos commented 5 years ago

I would like to share my experience working with the new subscribe feature. We have 4 different microservices, which use web3.eth.subscribe method and major problem is that after a day or few, a subscription is dropped (it seems it is Geth's fault), but we don't get any errors or anything. It just stops listening for new contract events. The temporary solution we found is to restart our applications regularly (once a day), but sometimes it doesn't help because subscription can be lost only after a few hours.

So to sum, it would be really nice to implement pulling algorithm using HTTP interface in web3 v1. Also, JSON-RPC2.0 Geth feature was marked as experimental not so long ago. For short-lived subscriptions, we haven't yet encountered any problems

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions