[Ethereum] How to get list of transaction for ERC20 token address

etherscan

Can anyone please help me to get list of transaction for ERC20 token similar to

https://api-ropsten.etherscan.io/api?module=account&action=txlist&address=0xd39bdb16d138e5219d013cba3d94c327bd246302&sort=asc

This is my ERC20 token address : 0xd39bdb16d138e5219d013cba3d94c327bd246302

I tried with this

http://api.etherscan.io/api?module=account&action=tokentx&address=0xd39bdb16d138e5219d013cba3d94c327bd246302&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken

But am getting no transactions found

enter image description here

But i can see transactions in etherscan

enter image description here

Best Answer

  1. Change module=account to module=logs
  2. Change action=tokentx to action=getLogs
  3. Add topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

The last one is the hash of an ERC20 Transfer event.

You can obtain it programmatically, for example, using web3.js v1.x:

const Web3 = require("web3");
const TRANSFER_EVENT = Web3.utils.keccak256("Transfer(address,address,uint256)");
console.log(TRANSFER_EVENT);
Related Topic