I am looking for a way to get all erc20 token transfers with specifying block number only.

For ETH there is already a way exists here.

I have done some search and found this method to find transfers of a specific address.


Is there any way to list all token transfers of a specific block by just providing a block number as a parameter in any way ?

1 Answer 1


You can use the Web3 APIs to pretty easily do this.

You just need to know that the ERC20 standard has a fixed ABI, and thus will have a fixed "method id"

Function: transfer(address _to, uint256 _value) 
MethodID: 0xa9059cbb

Any ERC20 transfer that happens in a block should start with 0xa9059cbb since this determines which function is called in a contract.

With this information, you just need to:

  • Get a block
  • Get all transaction hashes
  • Get all transactions
  • Check the first 10 characters match

Like so:

window.web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/<APIKEY>"));

async function getERC20Transfers(blockNumber) {
  let block = await web3.eth.getBlock(blockNumber);
  for (var transactionIndex in block.transactions) {
    let transactionHash = block.transactions[transactionIndex];
    let transaction = await web3.eth.getTransaction(transactionHash);
    if (transaction.input.substr(0,10) == "0xa9059cbb") {


You can find a working example which prints to your browser console here: https://jsfiddle.net/4sujyx5g/2/

  • Hi @Shawn, Thanks for the reply. Is there any way to get the exact to_address of the token transfer? Currently it shows contract address as to_address. But actual address is another address. For ex., see here
    – Deepak M
    Feb 25, 2019 at 11:43
  • You need to look at the content of the transaction, and decode the value for the "to" address. Should be pretty easy Feb 25, 2019 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.