0

I'm trying to get pending transactions to a certain contract using Infura. Is it possible to do that using eth_newFilter? Since apparently these filters only "trigger" from contract events, does that mean this idea is doomed? As in, when I get a tx from the filter, it can no longer be pending as it must be finished in order to trigger the filter?

If so, is it a suitable option to host my own full node instead and parse trough all pending transactions on my own? Doing that on Infura would result in a crapload of requests that I wouldn't want to burden their service with.

Any help is much appreciated.

1

eth_newFilter is used to receive and filter Ethereum logs. Logs are produced when a transaction is included in a block, hits a smart-contract and generates a log, which is not what you want.

You may want to look at web3js pending transaction subscriptions: https://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html#subscribe-pendingtransactions

const subscription = web3.eth.subscribe('pendingTransactions', function(error, result){
    if (!error)
        console.log(result);
})
.on("data", function(transaction){
    // Filter transaction if it hits your contract.
    console.log(transaction);
});

or directly using getPendingTransaction

web3.eth.getPendingTransactions().then(console.log);
  • 1
    thank you, that confirms my concerns. since the pendingTransations-filter only provides the tx hash (and querying additional details for every single pending transaction will probably get me IP banned on Infura), and getPendingTransacations is not implemented in Infura, it seems like there's no way around setting up my own node. – Mylolmania Jun 7 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.