1

I'm using web3j to analyze transactions. How can I get transactions of a specific contract (assuming I got it's address) in some time frame (or blocks interval) and how can I know if ERC20 tokens were transferred in a transaction once I get it?

1

You could use an API like the one provided by EtherScan or get an Infura account, but, alas, these are centralised solutions.

A fully decentralised method would be to run a full node and use the JSON-RPC commands.

Now you can query the list of transactions for your contract address. You can take their inputs and decode them, provided you have the contract's ABI. Here's some sample code doing that for an ERC20 transaction on Ropsten.

If you know the contract adheres to the ERC20 standard and the name of the function is transfer when the input is decoded, that's an ERC20 token transfer.

  • 1
    Thanks, I'm asking though specifically about a web3j (Java implementation) method of doing that. – forhas Jul 29 '18 at 14:45
  • 1
    I see, it might be worthwhile to mention you're looking for an implementation per se. – Paul Berg Jul 29 '18 at 14:50
  • 1
    The title and the question body mention "web3j", which is a java implementation for web3. You might have missed that part. – forhas Jul 29 '18 at 15:06

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.