1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

the best way to monitor my own account transactions in openethereum

Discussion in 'Finance' started by daidal, Aug 2, 2020 at 9:55 AM.

  1. daidal

    daidal Guest

    Please I want to know if I subscribe to pendingTransactions with web3 will it monitor and send notifications of accounts pending Transactions only or all pending transactions on Ethereum network. my project requires users to create Ethereum address now I need to monitor incoming transaction of each user address to complete their services


    var Web3 = require('web3')
    var Web3WsProvider = require('web3-providers-ws')

    var web3 = new Web3(new Web3WsProvider('ws://localhost:8547'))

    web3.eth.subscribe('pendingTransactions', function (error, result) {

    }).on("connected", function (subscriptionId) {
    console.log('subscriptionId :>> ', subscriptionId);
    })
    .on("data", function (transactionHash) {
    web3.eth.getTransaction(transactionHash)
    .then(function (transaction) {
    });

    })
    .on("error", console.error);

    web3.eth.subscribe('newBlockHeaders', function (error, result) {

    console.error(error);
    })
    .on("connected", function (subscriptionId) {
    console.log('subscriptionId :>> ', subscriptionId);
    }).on("data", (blockHeader) => {
    web3.eth.getBlock(blockHeader.hash, true).then(async (r) => {
    var txs = r.transactions
    console.log('acclist :>> ', acclist);
    txs.forEach(async (txId) => {

    console.log('txId :>> ', txId);
    })
    });

    })
    .on("error", console.error);

    Login To add answer/comment
     

Share This Page