3

I want to get all user's transactions from ERC20 compatible tokens. I can get all incoming transactions using this code:

const to = token.Transfer({_to: account}, {fromBlock: 0, toBlock: 'latest'});
transferEvent.get((_, transactions) => { console.log(transactions); });

But how can I get all transactions (incoming and outgoing) using web3 interface?

2

Unfortunately, you may pass only one filter object per query and there are no higher order logical operators like sum or intersection available.

I'd recommend querying for events twice (first for incoming, then for outgoing) and merge the results using sth like Array.concat(). A good token implementation should prevent self-sending so there shouldn't be duplicates, but obviously, it's best to check for that as well.

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.