Ethers.js: Unable to listen to Transfer Event

Created on 8 Nov 2018  路  5Comments  路  Source: ethers-io/ethers.js

Hi!

var ethers = require('ethers');

let provider = ethers.getDefaultProvider('kovan');

let topic = ethers.utils.id("Transfer(address,address,uint256)");

let filter = {
    topics: [ topic ]
}

provider.on(filter, (result) => {
    console.log(result);
});

I am trying to listen to ERC20 token transfer but I am not getting anything? Is there's something wrong with my code?

Version: "^4.0.7"

Thanks!

bug fixed

All 5 comments

I just tried your code on mainnet, which works fine. Once I point it at Kovan it seems to not generate events; I'm rewinding 100,000 blocks on Kovan, and find it hard to believe there are not any events, so I'm investigating now...

I think I found the problem. Internally ethers.js sets the address for all filters, in the case of no address, it is the empty string; this seems fine on mainnet, but Kovan is pickier.

The solution is to use address || null internally. I have made the change and am testing. Once the local testing is done, I'll push to GitHub, and it will take about 30 minutes for the test cases to run on Travis CI, then I'll publish to npm and update this issue.

Thanks! And sorry for the inconvenience.

sounds good! Thank you so much for fixing it so quickly

Heya! Can you pull the latest version 4.0.8 and let me know if it is fixed for you?

works! Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moshebeeri picture moshebeeri  路  3Comments

pcowgill picture pcowgill  路  3Comments

abhishekp1996 picture abhishekp1996  路  3Comments

jochenonline picture jochenonline  路  3Comments

PhABC picture PhABC  路  3Comments