2

I would like to do the equivalent of:

pendingEvent = web3.eth.filter('pending');

but only for a specific contract:

pendingContractEvent = myContractInstance.allEvents('pending');

or more specifically:

pendingContractEvent = myContractInstance.myEvent('pending');

When I do this, I get the event only when the transaction is included in a block (like 'latest').

2
  • Hope you solved issue, mark ans as resolved. So that it will help community to find ans very easy. Feb 15 '18 at 14:10
  • how to do this on web3py? on Python
    – AlexPC1
    Sep 25 '21 at 7:07
2

I would like to do the equivalent of:

pendingEvent = web3.eth.filter('pending');

Yes you can do using web3.eth.filter with options. By specifying address in options you can do archive your problem. I am just attaching sample code for ref.

var options = {address: <CONTRACTADDRESS>};
var filter = web3.eth.filter('pending', options);

filter.watch('pending',function (error, log) {
     console.log(log);
  }
});

Click below link for more details.

https://github.com/ethereum/wiki/wiki/JavaScript-API

2
  • Does not seem to work: I only have 7 tx on my contract and this filter sends me all pending tx. I have web3 version ^0.19.0
    – jfjobidon
    Feb 15 '18 at 17:11
  • If you're not providing contract I'd then you will get all pending trans Feb 15 '18 at 17:15

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.