Getting web3 eth filter is not a function while trying to monitor Ethereum blocks

0 votes

I'm trying to monitor for the 12th confirmation using web3. I use the following code:

let filter = web3.eth.filter('latest',
filter.watch(function(error, result) {
    if (!error) {
        let confirmedBlock = web3.eth.getBlock(web3.eth.blockNumber - 11)
        if (confirmedBlock.transactions.length > 0) {
            confirmedBlock.transactions.forEach(function(txId) {
                let transaction = web3.eth.getTransaction(txId)
                if (transaction.to == account) {
                    // Do something useful.
                    console.log("12 confirmations received");
                }
            })
        }
    }
});

however this throws the error web3.eth.filter is not a function

Oct 9, 2018 in Blockchain by slayer
• 29,350 points
2,362 views

1 answer to this question.

0 votes

It appears you are using web3.js v1.0. The way to subscribe to new block header information in v1 is web3.eth.subscribe('newBlockHeaders', callback);

For more information, see the docs.

answered Oct 9, 2018 by Omkar
• 69,210 points

Related Questions In Blockchain

0 votes
1 answer

Why is it downloading the blocks when I am trying to deploy the ethereum private network?

Once you have installed the Ethereum wallet, ...READ MORE

answered May 3, 2018 in Blockchain by Shashank
• 10,400 points
439 views
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,682 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,225 views
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
956 views
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,400 points
4,135 views
0 votes
1 answer

TypeError: XMLHttpRequest is not a function when using web3 on meteor server side

I had the same problem. Instead ethereum:web3 Meteor package ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,210 points
851 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP