Web3.js: Equivalent of web3.eth.filter("latest") in 1.0 with HTTP provider.

Created on 29 Jul 2017  路  4Comments  路  Source: ChainSafe/web3.js

couldn't find anything working similarly . It seems that is has been replaced by web3.eth.subscribe('newBlockHeaders' [, callback]); but that doesn't work with HTTP provider it seems ?

I'm getting bundle.js:51226 Error: The current provider doesn't support subscriptionsHttpProvider

Have i missed something or is it not supported anymore ? is it related to https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB ?

Most helpful comment

It does work over WS thought btw :

1-geth -dev --ws --wsport 8545 --wsaddr 0.0.0.0 --wsorigins "*" --wsapi "eth,web3" --minerthreads "1" --etherbase "fdfgfd" -mine

2 -

export var web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider("ws://localhost:8545"));
web3.eth.subscribe('newBlockHeaders', function(error, result){
  if (!error){
    console.log(error);
  } 
 }).on("data", function(blockHeader){
    // will return the block number.
   console.log(blockHeader.number);
});

also saw : https://github.com/ethereum/EIPs/issues/51 from @frozeman so i'm assuming it won't be supported over http anymore.

All 4 comments

I have the same issue

It does work over WS thought btw :

1-geth -dev --ws --wsport 8545 --wsaddr 0.0.0.0 --wsorigins "*" --wsapi "eth,web3" --minerthreads "1" --etherbase "fdfgfd" -mine

2 -

export var web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider("ws://localhost:8545"));
web3.eth.subscribe('newBlockHeaders', function(error, result){
  if (!error){
    console.log(error);
  } 
 }).on("data", function(blockHeader){
    // will return the block number.
   console.log(blockHeader.number);
});

also saw : https://github.com/ethereum/EIPs/issues/51 from @frozeman so i'm assuming it won't be supported over http anymore.

Please see this discussion: #937

I don't think it is appropriate to join the discussion at #937. But after I read along through whole thread, I think currently only WS and IPC can support web3.eth.event subscribing, for the stake of performance?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mishell-trickster picture mishell-trickster  路  3Comments

TinyWJL picture TinyWJL  路  3Comments

joeriexelmans picture joeriexelmans  路  3Comments

nivida picture nivida  路  3Comments

FradSer picture FradSer  路  3Comments