1

Many questions have been asked here but mostly they have been vague questions and/or answers so before marking as duplicate please read this one as its completely specific.

I have an ether account that deploys multiple forwarder contracts to be used as unique deposit addresses for the public, just like an exchange. I need to detect all the deposits made to these contract addresses or to the one main ether address.

Possible solution was to use web3 subscriptions as documented web3.eth.subscribe but the code(below) given as example doesn't log any deposits/transactions made to the account address to be honest it doesn't log any relevant information when it comes to logging the data with the contract address and/or account address. I tried removing all the filters and seeing all the logs, made a deposit to contract address but it never logged anything related to my account or contract address or the sender address for that matter.

var subscription = web3.eth.subscribe('logs', {
    address: '0x123456..',
    topics: ['0x12345...']
}, function(error, result){
    if (!error)
        console.log(result);
});

// unsubscribes the subscription
subscription.unsubscribe(function(error, success){
    if(success)
        console.log('Successfully unsubscribed!');
});

References:

https://github.com/ethereum/web3.js/issues/1752
How to programmatically detect and accept ETH and ERC20 deposits
How to detect ETH deposits into an Ether address?

I believe it was quite simple when it was web3.eth.filter but since web3 1.0 this is no more an option.

So what is the current recommended method for listening to the deposits?

  • I think you're still gonna have a problem with "Internal" transactions. AFAIK, Web3 doesn't detect these. – nyusternie Aug 17 '18 at 17:59
  • but it should detect the incoming deposits to a contract address (it's a forwarder contract). also is there some utility in some other language that does this in a more reliable manner, i would happily implement that as well. – Rohit Hazra Aug 17 '18 at 19:49
  • yes, "normal" txs should be detected just fine, but not "internal". i believe this is the same for all clients in any language. see here ethereum.stackexchange.com/a/6432/20276 – nyusternie Aug 18 '18 at 5:15
  • @nyusternie but I am unable to detect the normal eth transaction that is sent from an eth account (completely separate) to a forwarder contract address. – Rohit Hazra Aug 18 '18 at 9:47
  • I don't know if Web3 can do what you want, but I've used Ethers.js to subscribe for balance changes and it works great! But again, this WILL NOT detect "internal" txs, so its very likely your balance can become out of sync with your event updates. – nyusternie Aug 18 '18 at 12:58

Your Answer

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

Browse other questions tagged or ask your own question.